This commit is contained in:
Zeeshaun
2026-03-17 09:53:09 -05:00
parent cdcba54aa4
commit 1a0702a79a
590 changed files with 62058 additions and 0 deletions
@@ -0,0 +1,97 @@
using LCU.API.Internal.Operations.IncentiveApiLib;
using LCU.Library.Internal.IncentiveApiModels.Entities;
using LCU.Library.Internal.IncentiveApiModels.Enums;
using NUnit.Framework;
using System;
namespace Application.UnitTests.Entities
{
public class ActivityTest
{
[Test]
public void CopyActivityForTransfer_Basic()
{
var activityToCopy = new Activity
{
Accepted = new DateTime(2021, 9, 22),
DepartmentId = 2,
Detail = new ActivityDetail
{
AccountBalance = 100.00,
AccountNewBalance = 99.00,
AccountNumber = "888888",
AccountStatus = "Open",
AgreementNumber = "999",
BranchOrgName = "Org Name",
BranchOrgNbr = "Org Number",
DnaPersonNbr = "DNA number",
IsDebtProtectionEligible = true,
MemberName = "Member Name",
StationName = "Station Name",
SubjectOrgNbr = "Subject Org Number",
SubjectPersonNbr = "Subject Person Number",
IsGapInsuranceEligible = true,
},
EmployeeEmail = "[email protected]",
EmployeeId = "E0000",
MatchingActivityId = 0,
Product = Product.CheckCard,
SourceCreated = new DateTime(2021, 9, 22),
SourceId = "Source ID",
SourceSystem = SystemType.Dna,
State = ActivityState.PendingTransfer,
Type = ActivityType.Sale
};
var activityTransferAction = new ActivityTransferAction
{
NewActivityDepartmentId = 88,
NewActivityEmployeeId = "C0001",
ActivityStateBeforeTransfer = ActivityState.Accepted
};
var employeeEmailAddress = "[email protected]";
var result = Activity.CopyActivityForTransfer(activityToCopy, activityTransferAction, employeeEmailAddress);
Assert.AreEqual(true, result.Detail.IsDebtProtectionEligible);
Assert.AreEqual(0, result.Id);
Assert.AreEqual("888888", result.Detail.AccountNumber);
Assert.AreEqual(new DateTime(2021, 9, 22), result.Accepted);
Assert.AreEqual(new DateTime(2021, 9, 22), result.SourceCreated);
Assert.AreEqual(ActivityType.Sale, result.Type);
Assert.AreEqual(activityTransferAction.NewActivityDepartmentId, result.DepartmentId);
Assert.AreEqual(activityTransferAction.NewActivityEmployeeId, result.EmployeeId);
Assert.AreEqual(activityTransferAction.ActivityStateBeforeTransfer, result.State);
Assert.AreEqual(employeeEmailAddress, result.EmployeeEmail);
Assert.AreEqual(new DateTime(), result.LastUpdated);
Assert.AreEqual(null, result.LastUpdatedBy);
Assert.AreEqual(UserType.Associate, result.LastUpdatedByType);
Assert.AreEqual(new DateTime(), result.Created);
Assert.AreEqual(null, result.CreatedBy);
Assert.AreEqual(UserType.Associate, result.CreatedByType);
Assert.AreEqual(true, result.Detail.IsGapInsuranceEligible);
}
[Test]
public void ActivityTransformForView()
{
var activity = new Activity
{
Product = Product.CreditCard,
Type = ActivityType.Referral,
Detail = new ActivityDetail
{
Activity = new Activity
{
Product = Product.CreditCard,
Type = ActivityType.Referral,
},
AccountNumber = "1234567890"
}
};
var result = activity.TransformForView();
Assert.AreEqual("XXXXXX7890", result.Detail.AccountNumber);
}
}
}
@@ -0,0 +1,21 @@
using LCU.Library.Internal.IncentiveApiModels.Entities;
using LCU.Library.Internal.IncentiveApiModels.Enums;
using NUnit.Framework;
namespace Application.UnitTests.Entities
{
public class ActivityTransferActionTest
{
[Test]
public void IsEligibleForTransfer()
{
Assert.True(ActivityTransferAction.IsEligibleForTransfer(ActivityState.Accepted));
Assert.True(ActivityTransferAction.IsEligibleForTransfer(ActivityState.PendingReferral));
Assert.True(ActivityTransferAction.IsEligibleForTransfer(ActivityState.ManualReview));
Assert.False(ActivityTransferAction.IsEligibleForTransfer(ActivityState.Created));
Assert.False(ActivityTransferAction.IsEligibleForTransfer(ActivityState.PendingTransfer));
Assert.False(ActivityTransferAction.IsEligibleForTransfer(ActivityState.Rejected));
Assert.False(ActivityTransferAction.IsEligibleForTransfer(ActivityState.Transferred));
}
}
}
@@ -0,0 +1,18 @@
using LCU.Library.Internal.IncentiveApiModels.Entities;
using NUnit.Framework;
namespace Application.UnitTests.Entities
{
public class BusinessLineTest
{
[Test]
public void DetermineBusinessLine()
{
Assert.AreEqual(BusinessLine.TryLookup("HEADQUARTERS - SECURITY & FRAUD"),BusinessLine.MemberServices);
Assert.AreEqual(BusinessLine.TryLookup("GERMANTOWN - BRANCH"),BusinessLine.BranchOperations);
Assert.AreEqual(BusinessLine.TryLookup("HEADQUARTERS - OPERATIONS"),BusinessLine.Operations);
Assert.AreEqual(BusinessLine.TryLookup(null),BusinessLine.MemberServices);
Assert.AreEqual(BusinessLine.TryLookup(""),BusinessLine.MemberServices);
}
}
}
@@ -0,0 +1,41 @@
using LCU.Library.Internal.IncentiveApiModels.Entities;
using LCU.Library.Internal.IncentiveApiModels.Enums;
using NUnit.Framework;
namespace Application.UnitTests.Entities
{
public class CommissionTest
{
[Test]
public void HasSameRoleAndProduct_FullMatch_True()
{
var commission = new Commission { Role = Role.ABM, Product = Product.ATMCard };
var fullMatch = new Commission { Role = Role.ABM, Product = Product.ATMCard };
Assert.True(commission.HasSameRoleAndProduct(fullMatch));
}
[Test]
public void HasSameRoleAndProduct_NoMatch_False()
{
var commission = new Commission { Role = Role.ABM, Product = Product.ATMCard };
var noMatch = new Commission { Role = Role.Admin, Product = Product.NewChecking };
Assert.False(commission.HasSameRoleAndProduct(noMatch));
}
[Test]
public void HasSameRoleAndProduct_OnlyRoleMatch_False()
{
var commission = new Commission { Role = Role.ABM, Product = Product.ATMCard };
var roleMatch = new Commission { Role = Role.ABM, Product = Product.NewChecking };
Assert.False(commission.HasSameRoleAndProduct(roleMatch));
}
[Test]
public void HasSameRoleAndProduct_OnlyProductMatch_False()
{
var commission = new Commission { Role = Role.ABM, Product = Product.ATMCard };
var productMatch = new Commission { Role = Role.Admin, Product = Product.ATMCard };
Assert.False(commission.HasSameRoleAndProduct(productMatch));
}
}
}
@@ -0,0 +1,38 @@
using LCU.Library.Internal.IncentiveApiModels.Entities;
using NUnit.Framework;
namespace Application.UnitTests.Entities
{
public class DepartmentLineItemTest
{
[Test]
public void Validate_CalculatePercentage_TotalNonZero()
{
var departmentLineItem = new DepartmentLineItem
{
DepartmentName = "Test1",
PayoutTotal = 12
};
departmentLineItem.CalculatePercentage(12);
Assert.NotNull(departmentLineItem.PayoutPercentage);
Assert.AreEqual((decimal) 100, departmentLineItem.PayoutPercentage);
}
[Test]
public void Validate_CalculatePercentage_TotalZero()
{
var departmentLineItem = new DepartmentLineItem
{
DepartmentName = "Test1",
PayoutTotal = 12
};
departmentLineItem.CalculatePercentage(0);
Assert.NotNull(departmentLineItem.PayoutPercentage);
Assert.AreEqual((decimal) 0, departmentLineItem.PayoutPercentage);
}
}
}
@@ -0,0 +1,114 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using LCU.Library.Internal.IncentiveApiModels.Entities;
using LCU.Library.Internal.IncentiveApiModels.Enums;
using NUnit.Framework;
namespace Application.UnitTests.Entities
{
public class DepartmentTest
{
[Test]
public void Validate_OK()
{
var dept = new Department()
{
DepartmentName = "Test1",
BusinessLineCode = "MEMSRV",
State = DepartmentState.Active
};
var results = dept.Validate(new ValidationContext(dept));
Assert.IsEmpty(results);
}
[TestCase("BCHOPS", false)]
[TestCase("MEMSRV", false)]
[TestCase("OPS", false)]
[TestCase("TOAST", true)]
public void Validate_BusinessLineCode_OK(string businessLine, bool hasError)
{
var dept = new Department()
{
DepartmentName = "Test1",
BusinessLineCode = businessLine,
State = DepartmentState.Active
};
var results = dept.Validate(new ValidationContext(dept));
Assert.AreEqual(hasError,results.Any());
}
[Test]
public void Validate_Bad_BusinessLine()
{
var dept = new Department()
{
DepartmentName = "Test1",
BusinessLineCode = "THISISNOTAREALBUSINESSLINECODE",
State = DepartmentState.Active
};
var results = dept.Validate(new ValidationContext(dept));
Assert.NotNull(results);
Assert.AreEqual(1, results.Count());
Assert.AreEqual(results.First().ErrorMessage, "The supplied BusinessLineCode is not associated with any known BusinessLine");
}
[Test]
public void Validate_NullRegionCode_OK()
{
var department = new Department()
{
DepartmentName = "Test1",
BusinessLineCode = "MEMSRV",
RegionCode = null,
State = DepartmentState.Active
};
var results = department.Validate(new ValidationContext(department));
Assert.NotNull(results);
Assert.IsEmpty(results);
}
[TestCase("INVALID_REGION")]
[TestCase("")]
[TestCase(" ")]
public void Validate_BadRegionCode_IncludesValidationResult(string regionCode)
{
var department = new Department()
{
DepartmentName = "Test1",
BusinessLineCode = "MEMSRV",
RegionCode = regionCode,
State = DepartmentState.Active
};
var results = department.Validate(new ValidationContext(department));
Assert.NotNull(results);
Assert.AreEqual(1, results.Count());
Assert.AreEqual(results.First().ErrorMessage, "The supplied RegionCode is not associated with any known Region");
}
[TestCase("EAST")]
[TestCase("NORTH")]
[TestCase("SOUTH")]
[TestCase("WEST")]
public void Validate_RegionCode_OK(string regionCode)
{
var dept = new Department()
{
DepartmentName = "Test1",
BusinessLineCode = "MEMSRV",
RegionCode = regionCode,
State = DepartmentState.Active
};
var results = dept.Validate(new ValidationContext(dept));
Assert.NotNull(results);
Assert.IsEmpty(results);
}
}
}
@@ -0,0 +1,38 @@
using LCU.Library.Internal.IncentiveApiModels.Entities;
using NUnit.Framework;
namespace Application.UnitTests.Entities
{
public class RegionTest
{
[Test]
public void Regions_ContainsRegions()
{
var regions = Region.Regions;
Assert.AreEqual(4, regions.Count);
Assert.Contains(Region.North, regions);
Assert.Contains(Region.South, regions);
Assert.Contains(Region.East, regions);
Assert.Contains(Region.West, regions);
}
[Test]
public void FindByCode_ValidCodes_ReturnsRegion()
{
Assert.AreSame(Region.North, Region.FindByCode("NORTH"));
Assert.AreSame(Region.South, Region.FindByCode("SOUTH"));
Assert.AreSame(Region.East, Region.FindByCode("EAST"));
Assert.AreSame(Region.West, Region.FindByCode("WEST"));
}
[TestCase(null)]
[TestCase("")]
[TestCase(" ")]
[TestCase("INVALID")]
public void FindByCode_InvalidCodes_ReturnsNull(string regionCode)
{
Assert.Null(Region.FindByCode(regionCode));
}
}
}
@@ -0,0 +1,94 @@
using System.Linq;
using LCU.Library.Internal.IncentiveApiModels.Entities;
using NUnit.Framework;
namespace Application.UnitTests.Entities
{
public class RoleTest
{
[Test]
public void GetRolesList_OK()
{
var roles = Role.GetRolesList();
Assert.Contains(Role.Admin, roles);
Assert.Contains(Role.RegionalManager, roles);
Assert.Contains(Role.BM, roles);
Assert.Contains(Role.ABM, roles);
Assert.Contains(Role.BOM, roles);
Assert.Contains(Role.PFO, roles);
Assert.Contains(Role.Teller, roles);
Assert.Contains(Role.MSCTeamLead, roles);
Assert.Contains(Role.MSLO, roles);
Assert.Contains(Role.MSR, roles);
Assert.Contains(Role.OpsHelpDesk, roles);
Assert.Contains(Role.UniversalSpecialistPFO, roles);
Assert.Contains(Role.UniversalSpecialistTeller, roles);
Assert.Contains(Role.InStoreBranchManager, roles);
Assert.Contains(Role.InStoreAssistantBranchManager, roles);
Assert.Contains(Role.ManagementTrainee, roles);
Assert.Contains(Role.BusinessLineManager, roles);
Assert.Contains(Role.MISSING_ROLE, roles);
Assert.Contains(Role.UNKNOWN_ROLE, roles);
Assert.Contains(Role.Developer, roles);
Assert.Contains(Role.Mortgage, roles);
Assert.Contains(Role.LIC, roles);
Assert.Contains(Role.Manager, roles);
}
[Test]
public void DetermineRoleOrDefault_Ok()
{
var role = Role.DetermineRoleOrDefault("Admin");
Assert.AreEqual(Role.Admin, role);
var roleUnknownEmpty = Role.DetermineRoleOrDefault("");
Assert.AreEqual(Role.UNKNOWN_ROLE, roleUnknownEmpty);
var roleUnknown = Role.DetermineRoleOrDefault("NOT_REAL_HOPEFULLY");
Assert.AreEqual(Role.UNKNOWN_ROLE, roleUnknown);
}
[Test]
public void SearchRoles_OK()
{
var foundRoles = Role.SearchRoles("Admin");
Assert.Contains(Role.Admin, foundRoles);
Assert.AreEqual(2, foundRoles.Count());
foundRoles = Role.SearchRoles("Branch Manager");
Assert.Contains(Role.BM, foundRoles);
Assert.Contains(Role.ABM, foundRoles);
Assert.Contains(Role.InStoreBranchManager, foundRoles);
Assert.Contains(Role.InStoreAssistantBranchManager, foundRoles);
Assert.AreEqual(4, foundRoles.Count());
foundRoles = Role.SearchRoles("Developer");
Assert.Contains(Role.Developer, foundRoles);
Assert.AreEqual(1, foundRoles.Count());
foundRoles = Role.SearchRoles("Develop");
Assert.Contains(Role.Developer, foundRoles);
Assert.AreEqual(1, foundRoles.Count());
foundRoles = Role.SearchRoles("LIC");
Assert.Contains(Role.LIC, foundRoles);
Assert.AreEqual(2, foundRoles.Count());
foundRoles = Role.SearchRoles("LIC ");
Assert.Contains(Role.LIC, foundRoles);
Assert.AreEqual(2, foundRoles.Count());
foundRoles = Role.SearchRoles(" LIC");
Assert.Contains(Role.LIC, foundRoles);
Assert.AreEqual(2, foundRoles.Count());
foundRoles = Role.SearchRoles(" LIC ");
Assert.Contains(Role.LIC, foundRoles);
Assert.AreEqual(2, foundRoles.Count());
foundRoles = Role.SearchRoles(" lic ");
Assert.Contains(Role.LIC, foundRoles);
Assert.AreEqual(2, foundRoles.Count());
}
}
}
@@ -0,0 +1,315 @@
using System;
using LCU.Library.Internal.IncentiveApiModels.Entities;
using LCU.Library.Internal.IncentiveApiModels.Enums;
using NUnit.Framework;
namespace Application.UnitTests.Entities
{
public class UserDepartmentTest
{
private readonly AppUser _employee = new AppUser()
{
EmployeeId = "5",
PersonId = 0,
AdEmail = "[email protected]"
};
[Test]
public void NonConflictingAssignment_Diff_Dept()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Today,
EndDate = null
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 6,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Today,
EndDate = null
};
Assert.False(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
Assert.AreEqual(string.Empty, message);
}
[Test]
public void NonConflictingAssignment_Diff_User()
{
var employee2 = new AppUser()
{
EmployeeId = "6",
PersonId = 0,
AdEmail = "[email protected]"
};
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Today,
EndDate = null
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = employee2,
StartDate = DateTime.Today,
EndDate = null
};
Assert.False(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
Assert.AreEqual(string.Empty, message);
}
[Test]
public void ConflictingAssignment_Case_Null_Null()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Today,
EndDate = null
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Today,
EndDate = null
};
Assert.True(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
}
[Test]
public void ConflictingAssignment_Case_Null_Valid()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Parse("2021-01-01T00:00:00.000Z").ToUniversalTime(),
EndDate = null
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Parse("2021-07-01T00:00:00.000Z").ToUniversalTime(),
EndDate = DateTime.Parse("2021-07-31T23:59:00.000Z").ToUniversalTime()
};
Assert.True(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
}
[Test]
public void ConflictingAssignment_Case_Valid_Null_Before()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Today,
EndDate = DateTime.Today.AddDays(1)
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Today.AddDays(1),
EndDate = null
};
Assert.True(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
}
[Test]
public void NonConflictingAssignment_Case_Valid_Null_After()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Today,
EndDate = DateTime.Today.AddDays(1)
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Today.AddDays(2),
EndDate = null
};
Assert.False(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
}
[Test]
public void NonConflictingAssignment_Case_Valid_Valid_After()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Parse("2021-07-01T00:00:00.000Z").ToUniversalTime(),
EndDate = DateTime.Parse("2021-07-31T23:59:00.000Z").ToUniversalTime()
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Parse("2021-08-01T00:00:00.000Z").ToUniversalTime(),
EndDate = DateTime.Parse("2021-08-31T23:59:00.000Z").ToUniversalTime()
};
Assert.False(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
}
[Test]
public void NonConflictingAssignment_Case_Valid_Valid_Before()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Parse("2021-07-01T00:00:00.000Z").ToUniversalTime(),
EndDate = DateTime.Parse("2021-07-31T23:59:00.000Z").ToUniversalTime()
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Parse("2021-06-01T00:00:00.000Z").ToUniversalTime(),
EndDate = DateTime.Parse("2021-06-30T23:59:00.000Z").ToUniversalTime()
};
Assert.False(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
}
[Test]
public void ConflictingAssignment_Case_Valid_Valid_Overlap()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Today,
EndDate = DateTime.Today.AddDays(5)
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Today.AddDays(2),
EndDate = DateTime.Today.AddDays(10)
};
Assert.True(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
}
[Test]
public void ConflictingAssignment_Case_Overlap_IgnoreTimestamp()
{
var existingAssignment = new UserDepartment()
{
DepartmentId = 5,
Employee = _employee,
StartDate = DateTime.Parse("2021-07-01T00:00:00.000Z").ToUniversalTime(),
EndDate = DateTime.Parse("2021-07-05T12:00:00.000Z").ToUniversalTime()
};
var newAssignment = new UserDepartment()
{
// DepartmentID will be NULL.
Department = new Department()
{
Id = 5,
State = DepartmentState.Active,
DepartmentName = "Test",
BusinessLineCode = BusinessLine.Operations.Code
},
Employee = _employee,
StartDate = DateTime.Parse("2021-07-05T15:00:00.000Z").ToUniversalTime(),
EndDate = DateTime.Parse("2021-07-08T00:00:00.000Z").ToUniversalTime()
};
Assert.True(existingAssignment.IsConflictingAssignment(newAssignment, out string message));
}
}
}