public void UpdateTest() { //Set test Claim newClaim = new Claim(); newClaim.ClaimId = "1"; newClaim.ClaimType = ClaimType.Car; newClaim.Description = "Accident on I-69"; newClaim.DateOfIncident = new DateTime(2020, 1, 18); newClaim.DateOfClaim = new DateTime(2020, 1, 30); ClaimRepo newClaimRepo = new ClaimRepo(); //Can you add it ok newClaimRepo.AddClaimToLists(newClaim); //Update test newClaim.Description = "Accident on I-70"; newClaimRepo.UpdateExistingClaim("1", newClaim); //Does description update string expected2 = "Accident on I-70"; string actual2 = newClaim.Description; Assert.AreEqual(expected2, actual2); //Updated without issue }
public void GetTest() { //Set test Claim newClaim = new Claim(); newClaim.ClaimId = "1"; newClaim.ClaimType = ClaimType.Car; newClaim.Description = "Accident on I-69"; newClaim.DateOfIncident = new DateTime(2020, 1, 18); newClaim.DateOfClaim = new DateTime(2020, 1, 30); ClaimRepo newClaimRepo = new ClaimRepo(); newClaimRepo.AddClaimToLists(newClaim); //Get test Claim newClaim4 = newClaimRepo.GetClaimItemById("1"); Assert.IsNotNull(newClaim4); //Picked up a claim, pass }
public void DeleteTest() { Claim newClaim = new Claim(); newClaim.ClaimId = "1"; newClaim.ClaimType = ClaimType.Car; newClaim.Description = "Accident on I-69"; newClaim.DateOfIncident = new DateTime(2020, 1, 18); newClaim.DateOfClaim = new DateTime(2020, 1, 30); ClaimRepo newClaimRepo = new ClaimRepo(); //Add newClaimRepo.AddClaimToLists(newClaim); //Does it remove ok newClaimRepo.RemoveClaimItemFromLists("1"); Claim newClaim3 = newClaimRepo.GetClaimItemById("1"); Assert.IsNull(newClaim3); }
public void SetTest() { //Set test Claim newClaim = new Claim(); newClaim.ClaimId = "1"; newClaim.ClaimType = ClaimType.Car; newClaim.Description = "Accident on I-69"; newClaim.DateOfIncident = new DateTime(2020, 1, 18); newClaim.DateOfClaim = new DateTime(2020, 1, 30); ClaimRepo newClaimRepo = new ClaimRepo(); //Can you add it ok newClaimRepo.AddClaimToLists(newClaim); Claim newclaim2 = newClaimRepo.GetClaimItemById("1"); string expected = "Accident on I-69"; string actual = newclaim2.Description; Assert.AreEqual(expected, actual); //Created without issue and added to list }
//Creating new Claim Item private void CreateNewClaimItem() { Console.Clear(); Claim newClaim = new Claim(); //Claim Item Id Console.WriteLine("Enter the claim id:"); newClaim.ClaimId = Console.ReadLine(); bool keepRunningType = true; while (keepRunningType) { //Claim Type Console.WriteLine("Enter the claim type (Car,Home,Theft):"); //might need to verify correct value string claimtype = Console.ReadLine(); if (claimtype.ToUpper() == "CAR") { newClaim.ClaimType = ClaimType.Car; keepRunningType = false; } else if (claimtype.ToUpper() == "HOME") { newClaim.ClaimType = ClaimType.Home; keepRunningType = false; } else if (claimtype.ToUpper() == "THEFT") { newClaim.ClaimType = ClaimType.Theft; keepRunningType = false; } else { Console.WriteLine("Claim Type is invalid. Try again, press any key to continue...."); Console.ReadLine(); } } //Claim Description Console.WriteLine("Enter a claim description:"); newClaim.Description = Console.ReadLine(); //Claim Amount Console.WriteLine("Amount of Damage:"); string claimAmt = Console.ReadLine(); newClaim.ClaimAmt = Convert.ToDouble(claimAmt); //Claim DateOfIncident bool keepRunningDate = true; while (keepRunningDate) { Console.WriteLine("Date Of Accident (MM/DD/YYYY):"); string datestring = Console.ReadLine(); bool ValidClaimDate = DateValid(datestring); if (ValidClaimDate) { newClaim.DateOfIncident = ParseMyFormatDateTime(datestring); keepRunningDate = false; } else { Console.WriteLine("Date is not valid, try again, press any key to continue..."); Console.ReadLine(); } //DateTime dateofincident = DateTime.ParseExact(datestring, "MM/dd/yyyy", CultureInfo.InvariantCulture); //newClaim.DateOfIncident = dateofincident; } //Claim DateOfIncident bool keepRunningDate2 = true; while (keepRunningDate2) { //Claim DateOfClaim Console.WriteLine("Date of Claim (MM/DD/YYYY):"); string datestring2 = Console.ReadLine(); bool ValidClaimDate = DateValid(datestring2); if (ValidClaimDate) { DateTime dateofclaim = DateTime.ParseExact(datestring2, "MM/dd/yyyy", CultureInfo.InvariantCulture); newClaim.DateOfClaim = dateofclaim; keepRunningDate2 = false; } else { Console.WriteLine("Date is not valid, try again, press any key to continue..."); Console.ReadLine(); } } //Claim IsValid //Did not check future dates, could be an enhancement. if (((newClaim.DateOfClaim.AddDays(-30)) <= (newClaim.DateOfIncident)) & (newClaim.DateOfIncident < newClaim.DateOfClaim)) { newClaim.IsValid = true; } else { newClaim.IsValid = false; } if (newClaim.IsValid) { Console.WriteLine("The claim is valid."); _claimItemDirectory.AddClaimToLists(newClaim); } else { Console.WriteLine("The claim is not valid. System will not add invalid claim."); } }