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
119 lines
6.7 KiB
C#
119 lines
6.7 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;
|
|
|
|
[TestClass]
|
|
public class LotDispositionDMOTests {
|
|
|
|
#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 LotDispositionDMO(ILogger? logger, AppSettings appSettings) {
|
|
#pragma warning disable IDE0059
|
|
SetGlobalVars(logger, appSettings);
|
|
LotDispositionDMO lotDispositionDMO = new(appSettings);
|
|
// void DeleteAllLotDispoLot(int issueID);
|
|
// void DeleteCADocument(int CANo, int userID, string caTypeString);
|
|
// void DeleteLotDispoAttachment(int attachmentID);
|
|
// void DeleteLotDispoLot(int lotID);
|
|
AuditList[] auditLists = lotDispositionDMO.GetAuditList(appSettings.UserId).ToArray();
|
|
// Errors! // ChangeControlList[] changeControlLists = lotDispositionDMO.GetChangeControls(appSettings.UserId).ToArray();
|
|
CorrectiveAction[] correctiveActions = lotDispositionDMO.GetCorrectiveActionList(appSettings.UserId).ToArray();
|
|
LotDispoDepartment[] lotDispoDepartments = lotDispositionDMO.GetDepartments().ToArray();
|
|
IssuesViewModel[] issuesViewModels = lotDispositionDMO.GetDocuments().ToArray();
|
|
IssuesViewModel[] issuesViewModelsB = lotDispositionDMO.GetECNList(appSettings.UserId).ToArray();
|
|
// string GetFileName(string attachmentID);
|
|
// Attachment[] GetLotDispoAttachments(int issueID);
|
|
// LotDisposition GetLotDispositionItem(int issueID, out int isITAR, int userID);
|
|
// LotDisposition GetLotDispositionItemForRead(int issueID, out int isITAR, int userID);
|
|
IssuesViewModel[] issuesViewModelsC = lotDispositionDMO.GetLotDispositionList(appSettings.UserId).ToArray();
|
|
// Lot[] GetLotDispositionLots(int issueID);
|
|
// LotDispositionLotSummaryViewModel GetLotDispositionLotSummary(int issueID);
|
|
IssuesViewModel[] issuesViewModelsD = lotDispositionDMO.GetLotDispositions().ToArray();
|
|
LotStatusOptionViewModel[] lotStatusOptionViewModels = lotDispositionDMO.GetLotStatusOptions().ToArray();
|
|
// ScrapLot GetLotStausDetail(int issueID, string lotNumber);
|
|
IssuesViewModel[] issuesViewModelsE = lotDispositionDMO.GetMRBList(appSettings.UserId).ToArray();
|
|
// SPN_MRB[] GetMRBsFromSPN(string lotNumber);
|
|
OpenActionItemViewModel[] openActionItemViewModels = lotDispositionDMO.GetMyOpenActionItems(appSettings.UserId).ToArray();
|
|
// string[] GetRejectionOrginatorEmailList(int issueID).ToArray();
|
|
// ResponsibilityIssue[] GetResponsibilityIssueList(int responsibilityID);
|
|
Responsibility[] responsibilities = lotDispositionDMO.GetResponsibilityList().ToArray().ToArray();
|
|
// int GetRHLotCount(int issueID);
|
|
IssuesViewModel[] issuesViewModelsF = lotDispositionDMO.GetTaskList(appSettings.UserId).ToArray();
|
|
Users[] users = lotDispositionDMO.GetUserList().ToArray();
|
|
IssuesViewModel[] issuesViewModelsG = lotDispositionDMO.GetWorkRequests().ToArray();
|
|
// void InsertChildLot_NotInTheMRB(string lotNumber);
|
|
// void InsertComments(int issueID, string comments, int commentedBy);
|
|
// int InsertLot(Lot lot, bool getLotInfo);
|
|
// LotDisposition InsertLotDisposition(LotDisposition lotDispo);
|
|
// void InsertLotDispositionAttachment(Attachment attach);
|
|
// void ReleaseLockOnDocument(int userID, int issueID);
|
|
// Lot[] SearchLots(string searchText);
|
|
// int SubmitDocument(int issueID, bool peRequired, bool mrbRequired, int userID);
|
|
// void UpdateLotDispoLot(Lot lot);
|
|
// void UpdateLotDisposition(LotDisposition lotDispo);
|
|
// void UpdateLotScrapReleaseStatus(ScrapLot scrap);
|
|
// void UpdateLotStatus(ScrapLot lotStatus);
|
|
// void UpdateLotStatusAll(ScrapLot scrap, int lotStatus);
|
|
// void UpdateReasonForDisposition(int issueID, string reasonForDisposition);
|
|
if (lotDispositionDMO is null) { }
|
|
#pragma warning restore IDE0059
|
|
}
|
|
|
|
#if Release
|
|
[Ignore]
|
|
#endif
|
|
[TestMethod]
|
|
public void LotDispositionDMOIsAttachedOnly() {
|
|
_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)
|
|
LotDispositionDMO(_Logger, appSettings);
|
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
|
NonThrowTryCatch();
|
|
}
|
|
|
|
} |