// Helper method to display claim information private void ViewClaimByID(int claimID) { _claimQueue = claimManipulator.GetAllClaims(); foreach (var claim in _claimQueue) { Console.ForegroundColor = ConsoleColor.White; if (claimID == claim.ClaimID) { var claimWindow = claim.ClaimDate - claim.LossDate; Console.WriteLine($"{claim.ClaimID}. {claim.ClaimType} claim: {claim.ClaimDescription}\n" + $"Loss occurred on {claim.LossDate.ToShortDateString()} and was reported {claimWindow.Days} days later on {claim.ClaimDate.ToShortDateString()}.\n" + $"Loss amount is {string.Format(new CultureInfo("en-us", true), "{0:C}", claim.ClaimAmount)}"); if (claim.IsValid) { Console.ForegroundColor = ConsoleColor.DarkGreen; Console.WriteLine("This claim is valid.\n"); } else { Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("This claim is invalid and may require further investigation.\n"); } } } }
public void TestAddClaim() { // Arrange (Create and initialize variables) var lossDate = new DateTime(2020, 03, 14); var claimDate = new DateTime(2020, 03, 15); var claimExpiration = new TimeSpan(30, 0, 0, 0); bool isValid = claimDate <= lossDate + claimExpiration; var claim = new Claim(1, ClaimType.Vehicle, "Fender bender", 3000.00m, lossDate, claimDate, isValid); var claimTester = new ClaimCRUD(); int beginningCount = claimTester.GetAllClaims().Count; // Act (Add new claim to queue) claimTester.CreateClaim(claim); // Assert (Check the count of the claims queue to make sure it is greater than it was at the beginning) int endingCount = claimTester.GetAllClaims().Count; Assert.IsTrue(endingCount > beginningCount, "Add was not successful."); }
public void TestReadClaim() { // Arrange (Create and initialize variables) var lossDate = new DateTime(2019, 08, 12); var claimDate = new DateTime(2019, 09, 09); var claimExpiration = new TimeSpan(30, 0, 0, 0); bool isValid = claimDate <= lossDate + claimExpiration; var claim = new Claim(1, ClaimType.Home, "House fire", 150000.00m, lossDate, claimDate, isValid); var claimTester = new ClaimCRUD(); // Act (Add claim to queue) claimTester.CreateClaim(claim); // Assert (List of claims should not be null) Assert.IsNotNull(claimTester.GetAllClaims(), "Read was not successful"); }