166 lines
6.7 KiB
C#
166 lines
6.7 KiB
C#
using EDAViewer.Models;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
using Shared;
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.Net;
|
|
using System.Reflection;
|
|
|
|
namespace EDAViewer.Tests
|
|
{
|
|
|
|
[TestClass]
|
|
public class BackgroundTests : LoggingUnitTesting, IBackground
|
|
{
|
|
|
|
private static AppSettings _AppSettings;
|
|
private static string _WorkingDirectory;
|
|
private static Singleton.IBackground _Background;
|
|
private static BackgroundTests _LoggingUnitTesting;
|
|
internal static BackgroundTests LoggingUnitTesting => _LoggingUnitTesting;
|
|
|
|
public BackgroundTests() : base(testContext: null, declaringType: null)
|
|
{
|
|
if (_LoggingUnitTesting is null)
|
|
throw new Exception();
|
|
}
|
|
|
|
public BackgroundTests(TestContext testContext) : base(testContext, new StackFrame().GetMethod().DeclaringType)
|
|
{
|
|
}
|
|
|
|
[ClassInitialize]
|
|
public static void ClassInitialize(TestContext testContext)
|
|
{
|
|
if (_LoggingUnitTesting is null)
|
|
_LoggingUnitTesting = new BackgroundTests(testContext);
|
|
_LoggingUnitTesting.Logger.LogInformation(string.Concat(testContext.TestName, " - ClassInitialize"));
|
|
Assembly assembly = Assembly.GetExecutingAssembly();
|
|
_AppSettings = _LoggingUnitTesting.ConfigurationRoot.Get<AppSettings>();
|
|
Assert.IsFalse(string.IsNullOrEmpty(_AppSettings.WorkingDirectoryName));
|
|
_WorkingDirectory = Log.GetWorkingDirectory(assembly.GetName().Name, _AppSettings.WorkingDirectoryName);
|
|
_Background = new Singleton.Background(_LoggingUnitTesting.IsEnvironment, _AppSettings, _WorkingDirectory);
|
|
_Background.Update(_LoggingUnitTesting.Logger);
|
|
Assert.IsFalse(string.IsNullOrEmpty(_AppSettings.URLs));
|
|
Assert.IsFalse(string.IsNullOrEmpty(_AppSettings.Server));
|
|
Assert.IsFalse(string.IsNullOrEmpty(_AppSettings.MonARessource));
|
|
Assert.IsNotNull(_Background);
|
|
}
|
|
|
|
[ClassCleanup()]
|
|
public static void ClassCleanup()
|
|
{
|
|
if (!(_LoggingUnitTesting.Logger is null))
|
|
_LoggingUnitTesting.Logger.LogInformation("Cleanup");
|
|
if (!(_LoggingUnitTesting is null))
|
|
_LoggingUnitTesting.Dispose();
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsDevelopment))]
|
|
public void EdaDataCollectionPlansCallback_WindowsDevelopment()
|
|
{
|
|
MethodBase methodBase = new StackFrame().GetMethod();
|
|
_Logger.LogInformation($"Skipped - {methodBase.Name}");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsStaging))]
|
|
public void EdaDataCollectionPlansCallback_WindowsStaging()
|
|
{
|
|
_Background.EdaDataCollectionPlansCallback();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsProduction))]
|
|
public void EdaDataCollectionPlansCallback_WindowsProduction()
|
|
{
|
|
_Background.EdaDataCollectionPlansCallback();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
public void EdaDataCollectionPlansCallback()
|
|
{
|
|
EdaDataCollectionPlansCallback_WindowsDevelopment();
|
|
EdaDataCollectionPlansCallback_WindowsStaging();
|
|
EdaDataCollectionPlansCallback_WindowsProduction();
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsDevelopment))]
|
|
public void EDAOutputArchiveCallback_WindowsDevelopment()
|
|
{
|
|
MethodBase methodBase = new StackFrame().GetMethod();
|
|
_Logger.LogInformation($"Skipped - {methodBase.Name}");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsStaging))]
|
|
public void EDAOutputArchiveCallback_WindowsStaging()
|
|
{
|
|
MethodBase methodBase = new StackFrame().GetMethod();
|
|
_Logger.LogInformation($"Skipped - {methodBase.Name}");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsProduction))]
|
|
public void EDAOutputArchiveCallback_WindowsProduction()
|
|
{
|
|
_Background.EDAOutputArchiveCallback();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
public void EDAOutputArchiveCallback()
|
|
{
|
|
EDAOutputArchiveCallback_WindowsDevelopment();
|
|
EDAOutputArchiveCallback_WindowsStaging();
|
|
EDAOutputArchiveCallback_WindowsProduction();
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsDevelopment))]
|
|
public void LogPathCleanUpByWeekCallback_WindowsDevelopment()
|
|
{
|
|
MethodBase methodBase = new StackFrame().GetMethod();
|
|
_Logger.LogInformation($"Skipped - {methodBase.Name}");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsStaging))]
|
|
public void LogPathCleanUpByWeekCallback_WindowsStaging()
|
|
{
|
|
MethodBase methodBase = new StackFrame().GetMethod();
|
|
_Logger.LogInformation($"Skipped - {methodBase.Name}");
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
[TestMethod]
|
|
[TestCategory(nameof(IsEnvironment.Name.WindowsProduction))]
|
|
public void LogPathCleanUpByWeekCallback_WindowsProduction()
|
|
{
|
|
_Background.LogPathCleanUpByWeekCallback();
|
|
Assert.IsTrue(true);
|
|
}
|
|
|
|
void IBackground.LogPathCleanUpByWeekCallback()
|
|
{
|
|
LogPathCleanUpByWeekCallback_WindowsDevelopment();
|
|
LogPathCleanUpByWeekCallback_WindowsStaging();
|
|
LogPathCleanUpByWeekCallback_WindowsProduction();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// dotnet build --runtime win-x64
|
|
// dotnet test --runtime win-x64 --no-build --filter LogPathCleanUpByWeekCallback_WindowsProduction --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
|
|
// dotnet test --runtime win-x64 --no-build --filter "ClassName=EDAViewer.Tests.BackgroundTests & TestCategory=WindowsDevelopment" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
|
|
// dotnet test --runtime win-x64 --no-build --filter "ClassName=EDAViewer.Tests.BackgroundTests & TestCategory=WindowsStaging" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\")
|
|
// dotnet test --runtime win-x64 --no-build --filter "ClassName=EDAViewer.Tests.BackgroundTests & TestCategory=WindowsProduction" --% -- TestRunParameters.Parameter(name=\"Debug\", value=\"Debugger.IsAttached\") |