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
103 lines
5.6 KiB
C#
103 lines
5.6 KiB
C#
using Fab2ApprovalSystem.DMO;
|
|
using Fab2ApprovalSystem.Models;
|
|
using Fab2ApprovalSystem.ViewModels;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Fab2ApprovalTests.DMO;
|
|
|
|
[TestClass]
|
|
public class EngChangeNoticeDMOTests {
|
|
|
|
#pragma warning disable CS8618
|
|
|
|
private static ILogger? _Logger;
|
|
private static TestContext _TestContext;
|
|
private static WebApplicationFactory<Fab2ApprovalMKLink.Program> _WebApplicationFactory;
|
|
|
|
#pragma warning restore
|
|
|
|
public static void SetGlobalVars(ILogger? logger, AppSettings appSettings) {
|
|
logger?.LogDebug("Starting to set Fab2ApprovalSystem.Misc.GlobalVars");
|
|
Fab2ApprovalSystem.Misc.GlobalVars.AppSettings = appSettings;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.AttachmentUrl = appSettings.AttachmentUrl is null ? string.Empty : appSettings.AttachmentUrl;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.CA_BlankFormsLocation = appSettings.CABlankFormsLocation;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.DBConnection = appSettings.DBConnection;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.DB_CONNECTION_STRING = appSettings.DBConnectionString;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.hostURL = appSettings.HostURL;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.IS_INFINEON_DOMAIN = appSettings.IsInfineonDomain;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.MesaTemplateFiles = appSettings.MesaTemplateFiles;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.NDriveURL = appSettings.NDriveURL;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.SENDER_EMAIL = appSettings.SenderEmail;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.USER_ID = appSettings.UserId;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.USER_ISADMIN = appSettings.UserIsAdmin;
|
|
Fab2ApprovalSystem.Misc.GlobalVars.WSR_URL = appSettings.WSR_URL;
|
|
logger?.LogDebug("Finished setting Fab2ApprovalSystem.Misc.GlobalVars");
|
|
}
|
|
|
|
[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) { }
|
|
}
|
|
|
|
private static void EngChangeNoticeDMO(ILogger? logger, AppSettings appSettings) {
|
|
#pragma warning disable IDE0059
|
|
SetGlobalVars(logger, appSettings);
|
|
ECN_DMO ecnDMO = new();
|
|
// void CancelECN(int? ecnNumber);
|
|
// bool CanSubmitECN(int ecnNumber);
|
|
// void DeleteDocument(int ecnNumber, int userid, string ecnTypeString);
|
|
// void DeleteECNAttachment(int attachmentID);
|
|
// bool ECNApproveCancelled_ExpiredDocument(int issueID, byte step, string comments, out bool lastStep, int userID, int documentType);
|
|
// void ECNResetTECNAtRejection(int ecnNumber, int userID, int docType);
|
|
IssuesViewModel[] issuesViewModels = ecnDMO.GetAllTECNs().ToArray();
|
|
// IEnumerable<ApprovalLogHistory> GetECNApprovalLogHistory(int ecnNumber);
|
|
// IEnumerable<ECNAttachment> GetECNAttachments(int ecnNumber);
|
|
IssuesViewModel[] issuesViewModelsB = ecnDMO.GetECN_TECNPendingApprovals(appSettings.UserId).ToArray();
|
|
// string GetFileName(string attachmentID);
|
|
// IEnumerable<IssuesViewModel> GetMyConvertedTECNsToECNs(int userID, int maxDays);
|
|
// IEnumerable<IssuesViewModel> GetMyExpiredTECNs(int userID, int maxDays);
|
|
// IEnumerable<IssuesViewModel> GetMyExpiringTECNs(int userID, int maxDays);
|
|
// List<string> GetRejectionOrginatorEmailList(int ecnNumber);
|
|
int[] ints = ecnDMO.GetTECNNotificationUsers().ToArray();
|
|
// void InsertECNAttachment(ECNAttachment attach);
|
|
// int PCRBExists(int pcrb);
|
|
// void ReassignOriginatorECN(int ecnNumber, int newOriginatorID, string comments, int userID);
|
|
// void ReleaseLockOnDocument(int userID, int issueID);
|
|
// int ReSubmitDocument(int issueID, int userID, int documentType, out int allowedITAR, string descriptionOfChange, string reasonForChange, string ecnTypeString, out int newECNNumber, int categoryId);
|
|
// void SaveAfterSubmitByApprover(int ecnNumber, string implementationDetails);
|
|
// void SetToExecutionStep(int ecnNumber, int userid, int documentType, string ecnTypeString);
|
|
// int SubmitDocument(int issueID, int userID, int documentType, out int allowedITAR);
|
|
// int SubmitForCancellation(int issueID, byte currentStep, int userID, int documentType, string ecnType, int TECNOperationType);
|
|
// int SubmitTECNExtensionDocument(int issueID, int userID, int documentType, DateTime extensionDate);
|
|
// void TECNExtensionLog(int ecnNumber, DateTime extensionDate);
|
|
// void UpdateECNType(int ecnNumber, string ecnType);
|
|
if (ecnDMO is null) { }
|
|
#pragma warning restore IDE0059
|
|
}
|
|
|
|
#if Release
|
|
[Ignore]
|
|
#endif
|
|
[TestMethod]
|
|
public void EngChangeNoticeDMOIsAttachedOnly() {
|
|
_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)
|
|
EngChangeNoticeDMO(_Logger, appSettings);
|
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
|
NonThrowTryCatch();
|
|
}
|
|
|
|
} |