282 lines
8.6 KiB
C#
282 lines
8.6 KiB
C#
using APCViewer.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Logging.Abstractions;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Shared;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Net;
|
|
using System.Reflection;
|
|
|
|
namespace APCViewer.Tests
|
|
{
|
|
|
|
[TestClass]
|
|
public class HomeControllerTests : LoggingUnitTesting, IHomeController
|
|
{
|
|
|
|
private static long _Sequence;
|
|
private static WebClient _WebClient;
|
|
private static string _WorkingDirectory;
|
|
private static Singleton.IBackground _Background;
|
|
private static Controllers.HomeController _HomeController;
|
|
private static HomeControllerTests _LoggingUnitTesting;
|
|
internal static HomeControllerTests LoggingUnitTesting => _LoggingUnitTesting;
|
|
|
|
public HomeControllerTests() : base(testContext: null, declaringType: null)
|
|
{
|
|
if (_LoggingUnitTesting is null)
|
|
throw new Exception();
|
|
}
|
|
|
|
public HomeControllerTests(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType)
|
|
{
|
|
}
|
|
|
|
[ClassInitialize]
|
|
public static void ClassInitialize(TestContext testContext)
|
|
{
|
|
if (_LoggingUnitTesting is null)
|
|
_LoggingUnitTesting = new HomeControllerTests(testContext);
|
|
_LoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
|
|
_WebClient = new WebClient();
|
|
_Sequence = 637642624355251927;
|
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
|
_WorkingDirectory = Log.GetWorkingDirectory(assembly.GetName().Name, "IFXApps");
|
|
Type type = new StackFrame().GetMethod().DeclaringType;
|
|
_Background = new Singleton.Background(_LoggingUnitTesting.IsEnvironment, _LoggingUnitTesting.ConfigurationRoot, _WorkingDirectory);
|
|
_HomeController = new Controllers.HomeController(new NullLogger<Controllers.HomeController>(), _Background, httpContextAccessor: null);
|
|
_Background.Update(_LoggingUnitTesting.Logger, _WebClient);
|
|
Assert.IsNotNull(_Background);
|
|
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.URLs));
|
|
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.Server));
|
|
Assert.IsFalse(string.IsNullOrEmpty(_Background.AppSettings.MonARessource));
|
|
}
|
|
|
|
[ClassCleanup()]
|
|
public static void ClassCleanup()
|
|
{
|
|
if (!(_LoggingUnitTesting.Logger is null))
|
|
_LoggingUnitTesting.Logger.LogInformation("Cleanup");
|
|
if (!(_LoggingUnitTesting is null))
|
|
_LoggingUnitTesting.Dispose();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Background()
|
|
{
|
|
IActionResult IActionResult = _HomeController.Background();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.Background(bool? message_clear, bool? exceptions_clear, bool? set_is_primary_instance, bool? logistics_clear)
|
|
{
|
|
Background();
|
|
return null;
|
|
}
|
|
|
|
[Ignore]
|
|
[TestMethod]
|
|
public void DownloadCustomIPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.DownloadCustomIPDSF(ipdsf_file: "");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.DownloadCustomIPDSF(string ipdsf_file)
|
|
{
|
|
DownloadCustomIPDSF();
|
|
return null;
|
|
}
|
|
|
|
[Ignore]
|
|
[TestMethod]
|
|
public void DownloadCustomPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.DownloadCustomPDSF(pdsf_file: "");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.DownloadCustomPDSF(string pdsf_file)
|
|
{
|
|
DownloadCustomPDSF();
|
|
return null;
|
|
}
|
|
|
|
[Ignore]
|
|
[TestMethod]
|
|
public void DownloadIPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.DownloadIPDSF(_Sequence.ToString());
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.DownloadIPDSF(string id)
|
|
{
|
|
DownloadIPDSF();
|
|
return null;
|
|
}
|
|
|
|
[Ignore]
|
|
[TestMethod]
|
|
public void DownloadPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.DownloadPDSF(_Sequence.ToString());
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.DownloadPDSF(string id)
|
|
{
|
|
DownloadPDSF();
|
|
return null;
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Encode()
|
|
{
|
|
IActionResult IActionResult = _HomeController.Encode();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.Encode(string value)
|
|
{
|
|
Encode();
|
|
return null;
|
|
}
|
|
|
|
IActionResult IHomeController.Error()
|
|
{
|
|
throw new System.NotImplementedException();
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Index()
|
|
{
|
|
IActionResult IActionResult = _HomeController.Index();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.Index()
|
|
{
|
|
Index();
|
|
return null;
|
|
}
|
|
|
|
[Ignore]
|
|
[TestMethod]
|
|
public void IPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.IPDSF();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.IPDSF(string directory, string filter, bool is_gaN, bool is_Si)
|
|
{
|
|
IPDSF();
|
|
return null;
|
|
}
|
|
|
|
[Ignore]
|
|
[TestMethod]
|
|
public void PDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.PDSF();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.PDSF(string directory, string filter, bool is_gaN, bool is_Si)
|
|
{
|
|
PDSF();
|
|
return null;
|
|
}
|
|
|
|
[TestMethod]
|
|
public void Privacy()
|
|
{
|
|
IActionResult IActionResult = _HomeController.Privacy();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.Privacy()
|
|
{
|
|
Privacy();
|
|
return null;
|
|
}
|
|
|
|
[TestMethod]
|
|
public void TimePivot()
|
|
{
|
|
IActionResult IActionResult = _HomeController.TimePivot();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
IActionResult IHomeController.TimePivot(bool is_gaN, bool is_Si)
|
|
{
|
|
TimePivot();
|
|
return null;
|
|
}
|
|
|
|
[Ignore]
|
|
[TestMethod]
|
|
public void ViewCustomIPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.ViewCustomIPDSF(ipdsf_file: "");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
ContentResult IHomeController.ViewCustomIPDSF(string ipdsf_file)
|
|
{
|
|
ViewCustomIPDSF();
|
|
return null;
|
|
}
|
|
|
|
[Ignore]
|
|
[TestMethod]
|
|
public void ViewCustomPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.ViewCustomPDSF(pdsf_file: "");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
ContentResult IHomeController.ViewCustomPDSF(string pdsf_file)
|
|
{
|
|
ViewCustomPDSF();
|
|
return null;
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ViewIPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.ViewIPDSF(_Sequence.ToString());
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
ContentResult IHomeController.ViewIPDSF(string id)
|
|
{
|
|
ViewIPDSF();
|
|
return null;
|
|
}
|
|
|
|
[TestMethod]
|
|
public void ViewPDSF()
|
|
{
|
|
IActionResult IActionResult = _HomeController.ViewPDSF(_Sequence.ToString());
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
ContentResult IHomeController.ViewPDSF(string id)
|
|
{
|
|
ViewPDSF();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// dotnet build --runtime win-x64
|
|
// dotnet test --no-build --filter ViewPDSF
|
|
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.HomeTests & TestCategory=WindowsDevelopment" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
|
|
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.HomeTests & TestCategory=WindowsStaging" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
|
|
// dotnet test --runtime win-x64 --no-build --filter "ClassName=APCViewer.Tests.HomeTests & TestCategory=WindowsProduction" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\") |