Tasks 184281, 184799, 184800, 184801 and 184802
Align .editorconfig files Move Controller logic to DMO classes GlobalVars.AppSettings = Models.AppSettings.GetFromConfigurationManager(); Question EditorConfig Project level editorconfig Format White Spaces AppSetting when EnvironmentVariable not set Corrective Actions Tests Schedule Actions Tests DMO Tests Controller Tests Get ready to use VSCode IDE
This commit is contained in:
49
Fab2ApprovalTests/Utilities/EmailUtilitiesTests.cs
Normal file
49
Fab2ApprovalTests/Utilities/EmailUtilitiesTests.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using Fab2ApprovalSystem.Models;
|
||||
|
||||
using Fab2ApprovalSystem.Utilities;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Fab2ApprovalTests.Utilities;
|
||||
|
||||
[TestClass]
|
||||
public class EmailUtilitiesTests {
|
||||
|
||||
#pragma warning disable CS8618
|
||||
|
||||
private static ILogger? _Logger;
|
||||
private static TestContext _TestContext;
|
||||
private static WebApplicationFactory<Fab2ApprovalMKLink.Program> _WebApplicationFactory;
|
||||
|
||||
#pragma warning restore
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitAsync(TestContext testContext) {
|
||||
_TestContext = testContext;
|
||||
_WebApplicationFactory = new WebApplicationFactory<Fab2ApprovalMKLink.Program>();
|
||||
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||
_Logger = serviceProvider.GetRequiredService<ILogger<Fab2ApprovalMKLink.Program>>();
|
||||
}
|
||||
|
||||
private static void NonThrowTryCatch() {
|
||||
try { throw new Exception(); } catch (Exception) { }
|
||||
}
|
||||
|
||||
#if Release
|
||||
[Ignore]
|
||||
#endif
|
||||
[TestMethod]
|
||||
public void EmailUtilitiesIsAttachedOnly() {
|
||||
_Logger?.LogInformation("Starting Web Application");
|
||||
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
||||
AppSettings? appSettings = serviceProvider?.GetRequiredService<AppSettings>();
|
||||
Assert.IsTrue(appSettings is not null);
|
||||
if (System.Diagnostics.Debugger.IsAttached)
|
||||
EmailUtilities.SendNotification("mike.phares@infineon.com", [], "Test: Subject", "Body");
|
||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user