public void AddClaimToListTest()
        {
            //Arrange

            DateTime dateofIncident = new DateTime(2020, 01, 01);
            DateTime dateOfClaim    = new DateTime(2020, 02, 01);

            Claims claimItem = new Claims(1, ClaimType.Car, "Accident", 230.00, dateofIncident, dateOfClaim, true);

            //Act
            item.AddClaimToList(claimItem);

            //Assert
            int expected = 1;
            int actual   = item.GetClaimsList().Count;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void Arrange()
        {
            _claimRepo = new ClaimsRepository();
            _claim     = new Claim(101, DateTime.Now.AddDays(-10), 5000.0m);
            _claimRepo.AddClaimToList(_claim);

            _claim = new Claim(102, DateTime.Now.AddDays(-40), 5000.0m);
            _claimRepo.AddClaimToList(_claim);

            _claim = new Claim(101, DateTime.Now.AddDays(-10), 50000.0m);
            _claimRepo.AddClaimToList(_claim);

            _testCall1 = new Call(0, DateTime.Now, "");
            _testCall2 = new Call(1, DateTime.Now, "");
            _testCall3 = new Call(2, DateTime.Now, "");

            _callsList = new Queue <Call>();
            _callsList.Enqueue(_testCall1);
            _callsList.Enqueue(_testCall2);
            _callsList.Enqueue(_testCall3);
        }
        public void ClaimRepository_Tests_AddClaimToList()
        {
            //Arrange
            DateTime sampleAccidentDateOne   = new DateTime(2018, 9, 1, 12, 00, 00);
            DateTime sampleAccidentDateTwo   = new DateTime(2019, 1, 1, 12, 00, 00);
            DateTime sampleAccidentDateThree = new DateTime(1890, 2, 1, 12, 00, 00);
            DateTime sampleClaimDateOne      = new DateTime(2018, 9, 15, 12, 00, 00);
            DateTime sampleClaimDateTwo      = new DateTime(2019, 1, 2, 12, 00, 00);
            DateTime sampleClaimDateThree    = new DateTime(1904, 1, 3, 12, 00, 00);

            Claim sampleClaimOne   = new Claim(1, ClaimType.Home, "Mouse exploded", 4000.03m, sampleAccidentDateOne, sampleClaimDateOne);
            Claim sampleClaimTwo   = new Claim(2, ClaimType.Theft, "Mouse stole car", 4000.05m, sampleAccidentDateTwo, sampleAccidentDateThree);
            Claim sampleClaimThree = new Claim(3, ClaimType.Car, "carriage stolen", 210.56m, sampleAccidentDateThree, sampleClaimDateThree);

            _claimsRepository.AddClaimToList(sampleClaimOne);
            _claimsRepository.AddClaimToList(sampleClaimTwo);
            _claimsRepository.AddClaimToList(sampleClaimThree);

            //Assert
            int actual   = _claimsRepository.GetClaims().Count;
            int expected = 3;

            Assert.AreEqual(expected, actual);
        }
 public void Insert(Claim claim)
 {
     _claimRepo.AddClaimToList(claim);
 }
        //#8 - inside class, outside other methods; write methods for display options
        //Add claim to list
        //methods void - get input but don't have to return anything
        private void AddClaimToList()
        {
            //#11 clear content
            Console.Clear();
            Claims newClaim = new Claims();

            //Claim ID
            Console.WriteLine("Enter the Claim ID:");
            string idAsString = Console.ReadLine();

            newClaim.ClaimID = int.Parse(idAsString);

            //Type
            Console.WriteLine("Enter the claim type number: \n " +
                              "1. Car\n" +
                              "2. Home\n" +
                              "3. Theft");
            string claimAsString = Console.ReadLine();
            int    claimAsInt    = int.Parse(claimAsString);

            newClaim.TypeOfClaim = (ClaimType)claimAsInt;

            //Description
            Console.WriteLine("Enter the incident description.:");
            newClaim.Description = Console.ReadLine();

            //Amount
            Console.WriteLine("Enter the amount of damage: ");
            string amountAsString = Console.ReadLine();

            newClaim.ClaimAmount = double.Parse(amountAsString);

            //Date of Incident
            Console.WriteLine("Enter the date of the incident (Year/Month/Day): ");
            string incidentDateAsString = Console.ReadLine();

            newClaim.DateOfIncident = DateTime.Parse(incidentDateAsString);

            //Date of claim
            Console.WriteLine("Enter the date of the claim (Year/Month/Day)");
            string claimDateAsString = Console.ReadLine();

            newClaim.DateOfClaim = DateTime.Parse(claimDateAsString);

            //Is valid
            //Console.WriteLine("Is the claim valid (y/n)? ");
            //string claimValidString = Console.ReadLine().ToLower();

            if ((newClaim.DateOfClaim - newClaim.DateOfIncident).TotalDays <= 30)
            {
                Console.WriteLine("Claim is valid.");
            }
            else
            {
                Console.WriteLine("Claim is not valid");
            }

            //#9 - once all properties are set, need to call repository and add to list - create _claimsRepo (at top of program UI)
            //#10
            _claimsRepo.AddClaimToList(newClaim);
        }