Compare commits
5 Commits
f110fba4cd
...
704df4fa8c
Author | SHA1 | Date | |
---|---|---|---|
704df4fa8c | |||
e452047dfb | |||
bf3e46a784 | |||
909f358356 | |||
b3fb328b98 |
@ -58,6 +58,7 @@ public class AuditController : Controller {
|
|||||||
try {
|
try {
|
||||||
bool isAdmin = (bool)Session[GlobalVars.IS_ADMIN];
|
bool isAdmin = (bool)Session[GlobalVars.IS_ADMIN];
|
||||||
int userId = (int)Session[GlobalVars.SESSION_USERID];
|
int userId = (int)Session[GlobalVars.SESSION_USERID];
|
||||||
|
audit = auditDMO.GetAuditItem(issueID, userId);
|
||||||
AuditEdit auditEdit = auditDMO.GetAuditEdit(issueID, audit, isAdmin, userId);
|
AuditEdit auditEdit = auditDMO.GetAuditEdit(issueID, audit, isAdmin, userId);
|
||||||
if (auditEdit.RedirectToAction)
|
if (auditEdit.RedirectToAction)
|
||||||
return RedirectToAction("ReadOnlyAudit", new { auditNo = audit.AuditNo });
|
return RedirectToAction("ReadOnlyAudit", new { auditNo = audit.AuditNo });
|
||||||
|
@ -52,7 +52,7 @@ public class ChangeControlController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=pcrb/{issueID}";
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ public class ChangeControlController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/pcrb/{issueID}";
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=pcrb/{issueID}";
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class MRBController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=mrb/{issueID}";
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ public class MRBController : Controller {
|
|||||||
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
string encodedJwt = System.Net.WebUtility.UrlEncode(jwt);
|
||||||
string refreshToken = Session["RefreshToken"].ToString();
|
string refreshToken = Session["RefreshToken"].ToString();
|
||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=/mrb/{issueID}";
|
string mrbUrl = $"{GlobalVars.AppSettings.WasmClientUrl}/redirect?jwt={encodedJwt}&refreshToken={encodedRefreshToken}&redirectPath=mrb/{issueID}";
|
||||||
|
|
||||||
return Redirect(mrbUrl);
|
return Redirect(mrbUrl);
|
||||||
}
|
}
|
||||||
|
@ -401,7 +401,6 @@ public class AuditDMO {
|
|||||||
result.Is8DQA = "true";
|
result.Is8DQA = "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
audit = GetAuditItem(issueID, userId);
|
|
||||||
// transform audit users from string to list, delimited by a comma.
|
// transform audit users from string to list, delimited by a comma.
|
||||||
if (audit.Auditees == null) {
|
if (audit.Auditees == null) {
|
||||||
result.AuditeeNames = new List<string>();
|
result.AuditeeNames = new List<string>();
|
||||||
|
@ -90,16 +90,16 @@
|
|||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||||
"https://localhost:7255";
|
"https://localhost:7255";
|
||||||
string mrbUrl = wasmClientUrl + "/redirect?jwt=" + encodedJwt + "&refreshToken=" + encodedRefreshToken + "&redirectPath=/mrb/new";
|
string mrbUrl = wasmClientUrl + "/redirect?jwt=" + encodedJwt + "&refreshToken=" + encodedRefreshToken + "&redirectPath=mrb/new";
|
||||||
<li><a href="@mrbUrl">Create MRB</a></li>
|
<li><a href="@mrbUrl">Create MRB</a></li>
|
||||||
string pcrbUrl = wasmClientUrl + "/redirect?jwt=" + encodedJwt + "&refreshToken=" + encodedRefreshToken + "&redirectPath=/pcrb/new";
|
string pcrbUrl = wasmClientUrl + "/redirect?jwt=" + encodedJwt + "&refreshToken=" + encodedRefreshToken + "&redirectPath=pcrb/new";
|
||||||
<li><a href="@pcrbUrl">Create PCRB</a></li>
|
<li><a href="@pcrbUrl">Create PCRB</a></li>
|
||||||
} else {
|
} else {
|
||||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||||
"https://localhost:7255";
|
"https://localhost:7255";
|
||||||
string mrbUrl = wasmClientUrl + "/redirect?redirectPath=/mrb/new";
|
string mrbUrl = wasmClientUrl + "/redirect?redirectPath=mrb/new";
|
||||||
<li><a href="@mrbUrl">Create MRB</a></li>
|
<li><a href="@mrbUrl">Create MRB</a></li>
|
||||||
string pcrbUrl = wasmClientUrl + "/redirect?redirectPath=/pcrb/new";
|
string pcrbUrl = wasmClientUrl + "/redirect?redirectPath=pcrb/new";
|
||||||
<li><a href="@pcrbUrl">Create PCRB</a></li>
|
<li><a href="@pcrbUrl">Create PCRB</a></li>
|
||||||
}
|
}
|
||||||
@*<li><a href=@Url.Action("CreateWorkRequest", "LotTraveler")>Create Special Work Request</a></li>*@
|
@*<li><a href=@Url.Action("CreateWorkRequest", "LotTraveler")>Create Special Work Request</a></li>*@
|
||||||
@ -150,9 +150,9 @@
|
|||||||
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
string encodedRefreshToken = System.Net.WebUtility.UrlEncode(refreshToken);
|
||||||
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
string wasmClientUrl = Environment.GetEnvironmentVariable("FabApprovalWasmClientUrl") ??
|
||||||
"https://localhost:7255";
|
"https://localhost:7255";
|
||||||
string mrbUrl = wasmClientUrl + "/redirect?jwt=" + encodedJwt + "&refreshToken=" + encodedRefreshToken + "&redirectPath=/mrb/all";
|
string mrbUrl = wasmClientUrl + "/redirect?jwt=" + encodedJwt + "&refreshToken=" + encodedRefreshToken + "&redirectPath=mrb/all";
|
||||||
menu.Add().Text("MRB").Url(mrbUrl);
|
menu.Add().Text("MRB").Url(mrbUrl);
|
||||||
string pcrbUrl = wasmClientUrl + "/redirect?jwt=" + encodedJwt + "&refreshToken=" + encodedRefreshToken + "&redirectPath=/pcrb/all";
|
string pcrbUrl = wasmClientUrl + "/redirect?jwt=" + encodedJwt + "&refreshToken=" + encodedRefreshToken + "&redirectPath=pcrb/all";
|
||||||
menu.Add().Text("PCRB").Url(pcrbUrl);
|
menu.Add().Text("PCRB").Url(pcrbUrl);
|
||||||
//menu.Add().Text("Special Work Requests").Action("SpecialWorkRequestList", "Home");
|
//menu.Add().Text("Special Work Requests").Action("SpecialWorkRequestList", "Home");
|
||||||
//menu.Add().Text("PCRB").Action("ChangeControlList", "Home");
|
//menu.Add().Text("PCRB").Action("ChangeControlList", "Home");
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
trigger:
|
||||||
|
branches:
|
||||||
|
include:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
include:
|
||||||
|
- Fab2ApprovalSystem
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
coreVersion: "net8.0"
|
coreVersion: "net8.0"
|
||||||
targetFrameworkVersion: "v4.8"
|
targetFrameworkVersion: "v4.8"
|
||||||
|
@ -51,7 +51,7 @@ public class AuditDMOTests {
|
|||||||
try { throw new Exception(); } catch (Exception) { }
|
try { throw new Exception(); } catch (Exception) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AuditDMO(ILogger? logger, AppSettings appSettings) {
|
private static void AuditDMO(ILogger? logger, AppSettings appSettings, int auditNo, bool isAdmin) {
|
||||||
#pragma warning disable IDE0059
|
#pragma warning disable IDE0059
|
||||||
SetGlobalVars(logger, appSettings);
|
SetGlobalVars(logger, appSettings);
|
||||||
AuditDMO auditDMO = new(appSettings);
|
AuditDMO auditDMO = new(appSettings);
|
||||||
@ -61,25 +61,25 @@ public class AuditDMOTests {
|
|||||||
AuditedArea[] auditedAreas = auditDMO.GetAuditAreaList().ToArray();
|
AuditedArea[] auditedAreas = auditDMO.GetAuditAreaList().ToArray();
|
||||||
// IEnumerable<int> GetAuditFindingCategoryIdsByFindingId(int auditFindingsID);
|
// IEnumerable<int> GetAuditFindingCategoryIdsByFindingId(int auditFindingsID);
|
||||||
// AuditFindings GetAuditFindingsByID(int auditFindingsID);
|
// AuditFindings GetAuditFindingsByID(int auditFindingsID);
|
||||||
// IEnumerable<AuditFindings> GetAuditFindingsList(int auditNo);
|
AuditFindings[] auditFindings = auditDMO.GetAuditFindingsList(auditNo).ToArray();
|
||||||
// Audit GetAuditItem(int auditNo, appSettings.UserId);
|
Audit auditB = auditDMO.GetAuditItem(auditNo, appSettings.UserId);
|
||||||
// Audit GetAuditItemReadOnly(int auditNo, appSettings.UserId);
|
Audit auditC = new();
|
||||||
|
AuditEdit auditEdit = auditDMO.GetAuditEdit(auditNo, auditC, isAdmin, appSettings.UserId);
|
||||||
|
Audit auditD = auditDMO.GetAuditItemReadOnly(auditNo, appSettings.UserId);
|
||||||
Auditor[] auditors = auditDMO.GetAuditorList().ToArray();
|
Auditor[] auditors = auditDMO.GetAuditorList().ToArray();
|
||||||
// IEnumerable<AuditReportAttachment> GetAuditReportAttachments(int auditNo);
|
AuditReportAttachment[] auditReportAttachments = auditDMO.GetAuditReportAttachments(auditNo).ToArray();
|
||||||
// C_8DAuditedStandard[] c_8DAuditedStandards = auditDMO.GetAuditStandardList().ToArray();
|
// C_8DAuditedStandard[] c_8DAuditedStandards = auditDMO.GetAuditStandardList().ToArray();
|
||||||
AuditType[] auditTypes = auditDMO.GetAuditTypeList().ToArray();
|
AuditType[] auditTypes = auditDMO.GetAuditTypeList().ToArray();
|
||||||
// CAFindings GetCAFindingsItem(int caFindingsID);
|
// CAFindings GetCAFindingsItem(int caFindingsID);
|
||||||
// IEnumerable<AuditReportAttachment> GetCAFindingsItemAttachments(int caFindingsID);
|
// IEnumerable<AuditReportAttachment> GetCAFindingsItemAttachments(int caFindingsID);
|
||||||
// IEnumerable<CAFindings> GetCAFindingsList(int auditNo);
|
CAFindings[] caFindings = auditDMO.GetCAFindingsList(auditNo).ToArray();
|
||||||
CANoList[] cANoLists = auditDMO.GetCorrectiveActionNoList().ToArray();
|
CANoList[] cANoLists = auditDMO.GetCorrectiveActionNoList().ToArray();
|
||||||
// int GetOpenCACountByAuditNo(int auditNo);
|
int openCACountByAuditNo = auditDMO.GetOpenCACountByAuditNo(auditNo);
|
||||||
CAUserList[] cAUserLists = auditDMO.GetUserList().ToArray();
|
CAUserList[] cAUserLists = auditDMO.GetUserList().ToArray();
|
||||||
// Audit InsertAudit(Audit audit);
|
|
||||||
// void InsertAuditReportAttachment(AuditReportAttachment attach);
|
// void InsertAuditReportAttachment(AuditReportAttachment attach);
|
||||||
// void InsertCAFindings(CAFindings model);
|
// void InsertCAFindings(CAFindings model);
|
||||||
// int IsCAAssignedToAudit(int CANo, int auditNo);
|
// int IsCAAssignedToAudit(int CANo, int auditNo);
|
||||||
// void ReleaseLockOnDocument(appSettings.UserId, int issueID);
|
// void ReleaseLockOnDocument(appSettings.UserId, int issueID);
|
||||||
// void UpdateAudit(Audit audit, appSettings.UserId);
|
|
||||||
// void UpdateCAFindings(CAFindings model);
|
// void UpdateCAFindings(CAFindings model);
|
||||||
if (auditDMO is null) { }
|
if (auditDMO is null) { }
|
||||||
#pragma warning restore IDE0059
|
#pragma warning restore IDE0059
|
||||||
@ -89,13 +89,14 @@ public class AuditDMOTests {
|
|||||||
[Ignore]
|
[Ignore]
|
||||||
#endif
|
#endif
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void AuditDMOIsAttachedOnly() {
|
[DataRow(250, true)]
|
||||||
|
public void AuditDMOIsAttachedOnly(int auditNo, bool isAdmin) {
|
||||||
_Logger?.LogInformation("Starting Web Application");
|
_Logger?.LogInformation("Starting Web Application");
|
||||||
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
IServiceProvider? serviceProvider = _WebApplicationFactory?.Services.CreateScope().ServiceProvider;
|
||||||
AppSettings? appSettings = serviceProvider?.GetRequiredService<AppSettings>();
|
AppSettings? appSettings = serviceProvider?.GetRequiredService<AppSettings>();
|
||||||
Assert.IsTrue(appSettings is not null);
|
Assert.IsTrue(appSettings is not null);
|
||||||
if (System.Diagnostics.Debugger.IsAttached)
|
if (System.Diagnostics.Debugger.IsAttached)
|
||||||
AuditDMO(_Logger, appSettings);
|
AuditDMO(_Logger, appSettings, auditNo, isAdmin);
|
||||||
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
_Logger?.LogInformation("{TestName} completed", _TestContext?.TestName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
@ -25,25 +25,33 @@ public static class MockMemoryCacheService {
|
|||||||
public class PCRBServiceTests {
|
public class PCRBServiceTests {
|
||||||
private readonly Mock<ILogger<PCRBService>> _loggerMock;
|
private readonly Mock<ILogger<PCRBService>> _loggerMock;
|
||||||
private readonly Mock<IDalService> _dalServiceMock;
|
private readonly Mock<IDalService> _dalServiceMock;
|
||||||
private readonly Mock<IMemoryCache> _cacheMock;
|
private Mock<IMemoryCache> _cacheMock;
|
||||||
private readonly Mock<IUserService> _userServiceMock;
|
private readonly Mock<IUserService> _userServiceMock;
|
||||||
private readonly Mock<IApprovalService> _approvalServiceMock;
|
private readonly Mock<IApprovalService> _approvalServiceMock;
|
||||||
private readonly Mock<ISmtpService> _smtpServiceMock;
|
private readonly Mock<ISmtpService> _smtpServiceMock;
|
||||||
private readonly PCRBService _pcrbService;
|
private PCRBService _pcrbService;
|
||||||
|
|
||||||
|
private static IEnumerable<PCRB> PCRBS = new List<PCRB>() {
|
||||||
|
new PCRB {
|
||||||
|
PlanNumber = 1,
|
||||||
|
OwnerID = 1,
|
||||||
|
Title = "Test Title",
|
||||||
|
ChangeLevel = "Level 1",
|
||||||
|
ReasonForChange = "Test Reason",
|
||||||
|
ChangeDescription = "Test Description",
|
||||||
|
IsITAR = false,
|
||||||
|
CurrentStep = 1,
|
||||||
|
InsertTimeStamp = DateTime.Now,
|
||||||
|
LastUpdateDate = DateTime.Now,
|
||||||
|
Type = "Type 1"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private static IEnumerable<PCRBFollowUp> FOLLOW_UPS = new List<PCRBFollowUp>() {
|
private static IEnumerable<PCRBFollowUp> FOLLOW_UPS = new List<PCRBFollowUp>() {
|
||||||
new PCRBFollowUp { ID = 1, PlanNumber = 1, Step = 1, FollowUpDate = DateTime.Now }
|
new PCRBFollowUp { ID = 1, PlanNumber = 1, Step = 1, FollowUpDate = DateTime.Now }
|
||||||
};
|
};
|
||||||
|
|
||||||
public PCRBServiceTests() {
|
private static AppSettings appSettings = new AppSettings(
|
||||||
_loggerMock = new Mock<ILogger<PCRBService>>();
|
|
||||||
_dalServiceMock = new Mock<IDalService>();
|
|
||||||
_userServiceMock = new Mock<IUserService>();
|
|
||||||
_approvalServiceMock = new Mock<IApprovalService>();
|
|
||||||
_smtpServiceMock = new Mock<ISmtpService>();
|
|
||||||
_cacheMock = MockMemoryCacheService.GetMemoryCache(FOLLOW_UPS);
|
|
||||||
|
|
||||||
var appSettings = new AppSettings(
|
|
||||||
Company: "Infineon",
|
Company: "Infineon",
|
||||||
DbConnectionString: "connectionString",
|
DbConnectionString: "connectionString",
|
||||||
JwtAudience: "audience",
|
JwtAudience: "audience",
|
||||||
@ -56,6 +64,14 @@ public class PCRBServiceTests {
|
|||||||
WorkingDirectoryName: "workingDirectoryName"
|
WorkingDirectoryName: "workingDirectoryName"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public PCRBServiceTests() {
|
||||||
|
_loggerMock = new Mock<ILogger<PCRBService>>();
|
||||||
|
_dalServiceMock = new Mock<IDalService>();
|
||||||
|
_userServiceMock = new Mock<IUserService>();
|
||||||
|
_approvalServiceMock = new Mock<IApprovalService>();
|
||||||
|
_smtpServiceMock = new Mock<ISmtpService>();
|
||||||
|
_cacheMock = MockMemoryCacheService.GetMemoryCache(FOLLOW_UPS);
|
||||||
|
|
||||||
_pcrbService = new PCRBService(
|
_pcrbService = new PCRBService(
|
||||||
_loggerMock.Object,
|
_loggerMock.Object,
|
||||||
_dalServiceMock.Object,
|
_dalServiceMock.Object,
|
||||||
@ -67,6 +83,161 @@ public class PCRBServiceTests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateNewPCRB_WithValidParam_ShouldCreatePCRB() {
|
||||||
|
var pcrb = new PCRB {
|
||||||
|
OwnerID = 1,
|
||||||
|
Title = "Test Title",
|
||||||
|
ChangeLevel = "Level 1",
|
||||||
|
ReasonForChange = "Test Reason",
|
||||||
|
ChangeDescription = "Test Description",
|
||||||
|
IsITAR = false,
|
||||||
|
CurrentStep = 1,
|
||||||
|
InsertTimeStamp = DateTime.Now,
|
||||||
|
LastUpdateDate = DateTime.Now,
|
||||||
|
Type = "Type 1"
|
||||||
|
};
|
||||||
|
|
||||||
|
_dalServiceMock.Setup(d => d.ExecuteAsync(It.IsAny<string>(), pcrb))
|
||||||
|
.ReturnsAsync(1);
|
||||||
|
|
||||||
|
await _pcrbService.CreateNewPCRB(pcrb);
|
||||||
|
|
||||||
|
_dalServiceMock.Verify(d => d.ExecuteAsync(It.IsAny<string>(), pcrb), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateNewPCRB_WithNullParam_ShouldThrowException() {
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => _pcrbService.CreateNewPCRB(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateNewPCRB_WithDatabaseFailure_ShouldThrowException() {
|
||||||
|
var pcrb = new PCRB {
|
||||||
|
OwnerID = 1,
|
||||||
|
Title = "Test Title",
|
||||||
|
ChangeLevel = "Level 1",
|
||||||
|
ReasonForChange = "Test Reason",
|
||||||
|
ChangeDescription = "Test Description",
|
||||||
|
IsITAR = false,
|
||||||
|
CurrentStep = 1,
|
||||||
|
InsertTimeStamp = DateTime.Now,
|
||||||
|
LastUpdateDate = DateTime.Now,
|
||||||
|
Type = "Type 1"
|
||||||
|
};
|
||||||
|
|
||||||
|
_dalServiceMock.Setup(d => d.ExecuteAsync(It.IsAny<string>(), pcrb))
|
||||||
|
.ReturnsAsync(0);
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<Exception>(() => _pcrbService.CreateNewPCRB(pcrb));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateNewPCRB_WithDatabaseException_ShouldThrowException() {
|
||||||
|
var pcrb = new PCRB {
|
||||||
|
OwnerID = 1,
|
||||||
|
Title = "Test Title",
|
||||||
|
ChangeLevel = "Level 1",
|
||||||
|
ReasonForChange = "Test Reason",
|
||||||
|
ChangeDescription = "Test Description",
|
||||||
|
IsITAR = false,
|
||||||
|
CurrentStep = 1,
|
||||||
|
InsertTimeStamp = DateTime.Now,
|
||||||
|
LastUpdateDate = DateTime.Now,
|
||||||
|
Type = "Type 1"
|
||||||
|
};
|
||||||
|
|
||||||
|
_dalServiceMock.Setup(d => d.ExecuteAsync(It.IsAny<string>(), pcrb))
|
||||||
|
.Throws<Exception>();
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<Exception>(() => _pcrbService.CreateNewPCRB(pcrb));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdatePCRB_WithValidParam_ShouldUpdatePCRB() {
|
||||||
|
_cacheMock = MockMemoryCacheService.GetMemoryCache(PCRBS);
|
||||||
|
|
||||||
|
_pcrbService = new PCRBService(
|
||||||
|
_loggerMock.Object,
|
||||||
|
_dalServiceMock.Object,
|
||||||
|
_cacheMock.Object,
|
||||||
|
_userServiceMock.Object,
|
||||||
|
_approvalServiceMock.Object,
|
||||||
|
_smtpServiceMock.Object,
|
||||||
|
appSettings
|
||||||
|
);
|
||||||
|
|
||||||
|
var pcrb = new PCRB {
|
||||||
|
PlanNumber = 1,
|
||||||
|
OwnerID = 1,
|
||||||
|
Title = "Test Title",
|
||||||
|
ChangeLevel = "Level 1",
|
||||||
|
ReasonForChange = "Test Reason",
|
||||||
|
ChangeDescription = "Test Description",
|
||||||
|
IsITAR = false,
|
||||||
|
CurrentStep = 1,
|
||||||
|
LastUpdateDate = DateTime.Now,
|
||||||
|
ClosedDate = DateTime.Now,
|
||||||
|
Type = "Type 1"
|
||||||
|
};
|
||||||
|
|
||||||
|
_dalServiceMock.Setup(d => d.ExecuteAsync(It.IsAny<string>(), pcrb))
|
||||||
|
.ReturnsAsync(1);
|
||||||
|
|
||||||
|
await _pcrbService.UpdatePCRB(pcrb);
|
||||||
|
|
||||||
|
_dalServiceMock.Verify(d => d.ExecuteAsync(It.IsAny<string>(), pcrb), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdatePCRB_WithNullParam_ShouldThrowException() {
|
||||||
|
await Assert.ThrowsAsync<ArgumentNullException>(() => _pcrbService.UpdatePCRB(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdatePCRB_WithDatabaseFailure_ShouldThrowException() {
|
||||||
|
var pcrb = new PCRB {
|
||||||
|
PlanNumber = 1,
|
||||||
|
OwnerID = 1,
|
||||||
|
Title = "Test Title",
|
||||||
|
ChangeLevel = "Level 1",
|
||||||
|
ReasonForChange = "Test Reason",
|
||||||
|
ChangeDescription = "Test Description",
|
||||||
|
IsITAR = false,
|
||||||
|
CurrentStep = 1,
|
||||||
|
LastUpdateDate = DateTime.Now,
|
||||||
|
ClosedDate = DateTime.Now,
|
||||||
|
Type = "Type 1"
|
||||||
|
};
|
||||||
|
|
||||||
|
_dalServiceMock.Setup(d => d.ExecuteAsync(It.IsAny<string>(), pcrb))
|
||||||
|
.ReturnsAsync(0);
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<Exception>(() => _pcrbService.UpdatePCRB(pcrb));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task UpdatePCRB_WithDatabaseException_ShouldThrowException() {
|
||||||
|
var pcrb = new PCRB {
|
||||||
|
PlanNumber = 1,
|
||||||
|
OwnerID = 1,
|
||||||
|
Title = "Test Title",
|
||||||
|
ChangeLevel = "Level 1",
|
||||||
|
ReasonForChange = "Test Reason",
|
||||||
|
ChangeDescription = "Test Description",
|
||||||
|
IsITAR = false,
|
||||||
|
CurrentStep = 1,
|
||||||
|
LastUpdateDate = DateTime.Now,
|
||||||
|
ClosedDate = DateTime.Now,
|
||||||
|
Type = "Type 1"
|
||||||
|
};
|
||||||
|
|
||||||
|
_dalServiceMock.Setup(d => d.ExecuteAsync(It.IsAny<string>(), pcrb))
|
||||||
|
.Throws<Exception>();
|
||||||
|
|
||||||
|
await Assert.ThrowsAsync<Exception>(() => _pcrbService.UpdatePCRB(pcrb));
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task CreateFollowUp_WithValidParam_ShouldCreateFollowUp() {
|
public async Task CreateFollowUp_WithValidParam_ShouldCreateFollowUp() {
|
||||||
var followUp = new PCRBFollowUp {
|
var followUp = new PCRBFollowUp {
|
||||||
|
@ -15,6 +15,8 @@ public class SmtpClientWrapper : ISmtpClientWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Send(MailMessage message) {
|
public void Send(MailMessage message) {
|
||||||
|
message.Subject = message.Subject.Replace('\r', ' ').Replace('\n', ' ');
|
||||||
|
|
||||||
_client.Send(message);
|
_client.Send(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -78,16 +78,15 @@ public class PCRBService : IPCRBService {
|
|||||||
|
|
||||||
if (pcrb is null) throw new ArgumentNullException("PCRB cannot be null");
|
if (pcrb is null) throw new ArgumentNullException("PCRB cannot be null");
|
||||||
|
|
||||||
|
pcrb.LastUpdateDate = DateTime.Now;
|
||||||
|
|
||||||
StringBuilder queryBuilder = new();
|
StringBuilder queryBuilder = new();
|
||||||
queryBuilder.Append("insert into CCChangeControl (OwnerID, Title, ChangeLevel, ReasonForChange, ");
|
queryBuilder.Append("insert into CCChangeControl (OwnerID, Title, ChangeLevel, ReasonForChange, ");
|
||||||
queryBuilder.Append("ChangeDescription, IsITAR, CurrentStep, InsertTimeStamp, LastUpdateDate) ");
|
queryBuilder.Append("ChangeDescription, IsITAR, CurrentStep, InsertTimeStamp, LastUpdateDate, Type) ");
|
||||||
queryBuilder.Append($"values ({pcrb.OwnerID}, '{pcrb.Title}', '{pcrb.ChangeLevel}', ");
|
queryBuilder.Append("values (@OwnerID, @Title, @ChangeLevel, @ReasonForChange, @ChangeDescription, ");
|
||||||
queryBuilder.Append($"'{pcrb.ReasonForChange}', '{pcrb.ChangeDescription}', ");
|
queryBuilder.Append("@IsITAR, @CurrentStep, @InsertTimeStamp, @LastUpdateDate, @Type)");
|
||||||
queryBuilder.Append($"{Convert.ToInt32(pcrb.IsITAR)}, {pcrb.CurrentStep}, ");
|
|
||||||
queryBuilder.Append($"'{pcrb.InsertTimeStamp.ToString("yyyy-MM-dd HH:mm:ss")}', ");
|
|
||||||
queryBuilder.Append($"'{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}')");
|
|
||||||
|
|
||||||
int rowsCreated = await _dalService.ExecuteAsync(queryBuilder.ToString());
|
int rowsCreated = await _dalService.ExecuteAsync(queryBuilder.ToString(), pcrb);
|
||||||
|
|
||||||
if (rowsCreated <= 0) throw new Exception("unable to insert new PCRB in the database");
|
if (rowsCreated <= 0) throw new Exception("unable to insert new PCRB in the database");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -198,18 +197,16 @@ public class PCRBService : IPCRBService {
|
|||||||
|
|
||||||
if (pcrb is null) throw new ArgumentNullException("PCRB cannot be null");
|
if (pcrb is null) throw new ArgumentNullException("PCRB cannot be null");
|
||||||
|
|
||||||
StringBuilder queryBuilder = new();
|
pcrb.LastUpdateDate = DateTime.Now;
|
||||||
queryBuilder.Append($"update CCChangeControl set OwnerID={pcrb.OwnerID}, ");
|
|
||||||
queryBuilder.Append($"Title='{pcrb.Title.Replace("'", "''")}', ChangeLevel='{pcrb.ChangeLevel}', ");
|
|
||||||
queryBuilder.Append($"CurrentStep={pcrb.CurrentStep}, ReasonForChange='{pcrb.ReasonForChange.Replace("'", "''")}', ");
|
|
||||||
queryBuilder.Append($"ChangeDescription='{pcrb.ChangeDescription.Replace("'", "''")}', ");
|
|
||||||
queryBuilder.Append($"IsITAR={Convert.ToInt32(pcrb.IsITAR)}, ");
|
|
||||||
queryBuilder.Append($"InsertTimeStamp='{pcrb.InsertTimeStamp.ToString("yyyy-MM-dd HH:mm:ss")}', ");
|
|
||||||
queryBuilder.Append($"ClosedDate='{pcrb.ClosedDate.ToString("yyyy-MM-dd HH:mm:ss")}', ");
|
|
||||||
queryBuilder.Append($"LastUpdateDate='{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}' ");
|
|
||||||
queryBuilder.Append($"where PlanNumber={pcrb.PlanNumber}");
|
|
||||||
|
|
||||||
int rowsAffected = await _dalService.ExecuteAsync(queryBuilder.ToString());
|
StringBuilder queryBuilder = new();
|
||||||
|
queryBuilder.Append("update CCChangeControl set OwnerID=@OwnerID, Title=@Title, ChangeLevel=@ChangeLevel, ");
|
||||||
|
queryBuilder.Append("Type=@Type, CurrentStep=@CurrentStep, ReasonForChange=@ReasonForChange, ");
|
||||||
|
queryBuilder.Append("ChangeDescription=@ChangeDescription, IsITAR=@IsITAR, ClosedDate=@ClosedDate, ");
|
||||||
|
queryBuilder.Append("LastUpdateDate=@LastUpdateDate ");
|
||||||
|
queryBuilder.Append($"where PlanNumber=@PlanNumber");
|
||||||
|
|
||||||
|
int rowsAffected = await _dalService.ExecuteAsync(queryBuilder.ToString(), pcrb);
|
||||||
|
|
||||||
if (rowsAffected <= 0) throw new Exception("unable to perform update in database");
|
if (rowsAffected <= 0) throw new Exception("unable to perform update in database");
|
||||||
|
|
||||||
|
@ -137,6 +137,20 @@
|
|||||||
<MudSelectItem Value="@("Other Site + Mesa - Class 2")" />
|
<MudSelectItem Value="@("Other Site + Mesa - Class 2")" />
|
||||||
<MudSelectItem Value="@("Mesa - Class 3")" />
|
<MudSelectItem Value="@("Mesa - Class 3")" />
|
||||||
</MudSelect>
|
</MudSelect>
|
||||||
|
<MudSelect T="string"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
Required
|
||||||
|
Clearable
|
||||||
|
AnchorOrigin="Origin.BottomCenter"
|
||||||
|
Disabled="@pcrbIsSubmitted"
|
||||||
|
@bind-Value="@pcrb.Type"
|
||||||
|
Text="@pcrb.Type"
|
||||||
|
Label="Change Type">
|
||||||
|
<MudSelectItem Value="@("Cost Savings")" />
|
||||||
|
<MudSelectItem Value="@("Process Efficiency")" />
|
||||||
|
<MudSelectItem Value="@("Process Improvement")" />
|
||||||
|
<MudSelectItem Value="@("Business Continuity")" />
|
||||||
|
</MudSelect>
|
||||||
<MudCheckBox Disabled="@pcrbIsSubmitted"
|
<MudCheckBox Disabled="@pcrbIsSubmitted"
|
||||||
Color="Color.Tertiary"
|
Color="Color.Tertiary"
|
||||||
@bind-Value=pcrb.IsITAR
|
@bind-Value=pcrb.IsITAR
|
||||||
@ -152,6 +166,11 @@
|
|||||||
Value="@DateTimeUtilities.GetDateAsStringMinDefault(pcrb.LastUpdateDate)"
|
Value="@DateTimeUtilities.GetDateAsStringMinDefault(pcrb.LastUpdateDate)"
|
||||||
Label="Last Update"
|
Label="Last Update"
|
||||||
Variant="Variant.Outlined" />
|
Variant="Variant.Outlined" />
|
||||||
|
<MudTextField Disabled="true"
|
||||||
|
T="string"
|
||||||
|
Value="@DateTimeUtilities.GetDateAsStringMaxDefault(pcrb.ClosedDate)"
|
||||||
|
Label="Complete Date"
|
||||||
|
Variant="Variant.Outlined" />
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
|
|
||||||
<MudPaper Outlined="true"
|
<MudPaper Outlined="true"
|
||||||
|
@ -23,4 +23,5 @@ public class PCRB {
|
|||||||
public DateTime InsertTimeStamp { get; set; } = DateTimeUtilities.MIN_DT;
|
public DateTime InsertTimeStamp { get; set; } = DateTimeUtilities.MIN_DT;
|
||||||
public DateTime LastUpdateDate { get; set; } = DateTimeUtilities.MIN_DT;
|
public DateTime LastUpdateDate { get; set; } = DateTimeUtilities.MIN_DT;
|
||||||
public DateTime ClosedDate { get; set; } = DateTimeUtilities.MAX_DT;
|
public DateTime ClosedDate { get; set; } = DateTimeUtilities.MAX_DT;
|
||||||
|
public string Type { get; set; } = "";
|
||||||
}
|
}
|
Reference in New Issue
Block a user