Removed nugetSource from pipeline Removed more comments Created Static Classes for most DMO / Controller Classes Push ConfigurationManager.AppSettings to controller Align Tests with other Projects
107 lines
5.7 KiB
C#
107 lines
5.7 KiB
C#
using System;
|
|
|
|
using Fab2ApprovalSystem.DMO;
|
|
using Fab2ApprovalSystem.Models;
|
|
|
|
using Microsoft.AspNetCore.Mvc.Testing;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
namespace Fab2ApprovalTests.DMO;
|
|
|
|
[TestClass]
|
|
public class LotTravelerDMOTests {
|
|
|
|
#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 LotTravelerDMO(ILogger? logger, AppSettings appSettings) {
|
|
#pragma warning disable IDE0059
|
|
SetGlobalVars(logger, appSettings);
|
|
LotTravelerDMO lotTravelerDMO = new(appSettings);
|
|
// int CanAddLocationOperation(LTLotTravelerHoldSteps model);
|
|
// int CreateLotTravelerRevision(LTLotTravelerHoldSteps model, int userID);
|
|
// void CreateTraveler(int ltLotID, int workRequestID, int UserID);
|
|
// int CreateWorkRequestRevision(LTWorkRequest data, int userID);
|
|
// void DeleteLot(int ltLotID);
|
|
// IEnumerable<LTLot> GetLotList(int workRequestID);
|
|
// IEnumerable<LTLot> GetLotListBasedOnSWRNumber(int swrNumber);
|
|
// IEnumerable<LotWithTraveler> GetLotsWithTraveler(int workRequestID);
|
|
// LTLotTravelerHeaderViewModel GetLotTravelerHeaderForReadOnly(int ltLotID, int revisionNumber);
|
|
// LTLotTravelerHeaderViewModel GetLotTravelerHeaderForUpdate(int ltLotID, int UserID);
|
|
// IEnumerable<LTLotTravelerHoldSteps> GetLotTravelerHolStepsByRevision(int ltLotID, int revisionNumber);
|
|
// IEnumerable<RevisionHistory> GetLotTravelerRevisionHistory(int lotID);
|
|
// IEnumerable<LTLotTravelerHoldSteps> GetLotTravHoldSteps(int ltLotID);
|
|
// IEnumerable<LTLotTravelerHoldSteps> GetLotTravHoldStepsCompleted(int ltLotID);
|
|
// IEnumerable<LTLotTravelerHoldSteps> GetLotTravHoldStepsPending(int ltLotID);
|
|
// LotTravelerPdf GetLotTravlerPdf(int ltLotID, int revisionNumber);
|
|
// List<Revision> GetLotTravRevisions(int ltLotID);
|
|
// List<string> GetRejectionOrginatorEmailList(int workRequestID);
|
|
// IEnumerable<ApprovalLogHistory> GetWorkReqApprovalLogHistory(int swrNumber);
|
|
// IEnumerable<RevisionHistory> GetWorkReqRevisionHistory(int swrNumber);
|
|
// List<Revision> GetWorkReqRevisions(int swrNumber);
|
|
// void InsertLot(LTLot lot);
|
|
// int InsertLotTravelerHoldStep(LTLotTravelerHoldSteps model, int userID);
|
|
// void ReassignOriginator(int workRequestID, int newOriginatorID, string comments, int userID);
|
|
// void ReleaseLockOnDocument(int userID, int workRequestID);
|
|
// void ReleaseLockOnLotTravelerUpdateDoc(int userID, int ltLotID);
|
|
// void RestoreLotTravToPrevRevision(int prevLotTravRevID, int newLotTravRevID);
|
|
// int SubmitDocument(int workRequestID, int userID, int documentType, out int allowedITAR);
|
|
// int UpdateLotTravelerHoldStep(LTLotTravelerHoldSteps model, int userID);
|
|
// void UpdateLotTravlerExecution(int lotTravHoldStepID, string taskComments, bool CompletedFlag, int userID);
|
|
// int UpdateRevisedLotTravelerHoldStep(LTLotTravelerHoldSteps model, int userID);
|
|
if (lotTravelerDMO is null) { }
|
|
#pragma warning restore IDE0059
|
|
}
|
|
|
|
#if Release
|
|
[Ignore]
|
|
#endif
|
|
[TestMethod]
|
|
public void LotTravelerDMOIsAttachedOnly() {
|
|
_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)
|
|
LotTravelerDMO(_Logger, appSettings);
|
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
|
NonThrowTryCatch();
|
|
}
|
|
|
|
} |