public void Arrange()
        {
            _repo  = new ClaimRepo();
            _claim = new Claim(3, TypeOfClaim.Home, "stolen ring", 200.00, DateTime.Parse("12/24/2017"), DateTime.Parse("01/05/2018"));

            _repo.CreateANewClaimToQueue(_claim);
        }
        public void AddClaimToQueue_ShouldGetNotNull()
        {
            //Arrange

            //Act
            _repo.CreateANewClaimToQueue(_claim);
            Claim claimFromRepo = _repo.GetClaimByIDViaQueue(3);

            //Assert
            Assert.IsNotNull(claimFromRepo);
        }
Exemple #3
0
        public void CreateNewClaim()
        {
            Console.Clear();
            Claim newClaim = new Claim();

            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Creating a New Claim\n");
            Console.ResetColor();

            bool endErrorCheck = false;

            while (endErrorCheck == false)
            {
                int claimNumber = 0;

                Console.WriteLine("Enter the new claim ID:");

                if (int.TryParse(Console.ReadLine(), out int result) == true)
                {
                    claimNumber = result;
                }

                if (claimNumber <= 0)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\nThe claim ID must be numeric and greater than zero.\n");
                    Console.ResetColor();
                }
                else
                {
                    Claim tempNumber = _claimRepo.GetClaimByIDViaQueue(claimNumber);
                    if (tempNumber != null)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("\nThis claim ID already exists. Please select a new ID.\n");
                        Console.ResetColor();
                    }
                    else
                    {
                        endErrorCheck    = true;
                        newClaim.ClaimID = claimNumber;
                    }
                }
            }
            Console.WriteLine("\nEnter the Claim Type: \n" +
                              "For Car Enter 1\n" +
                              "For Home Enter 2\n" +
                              "For Theft Enter 3");

            bool errorCheck = true;

            while (errorCheck == true)
            {
                string input = Console.ReadLine();
                switch (input)
                {
                case "1":
                    newClaim.ClaimType = TypeOfClaim.Car;
                    errorCheck         = false;
                    break;

                case "2":
                    newClaim.ClaimType = TypeOfClaim.Home;
                    errorCheck         = false;
                    break;

                case "3":
                    newClaim.ClaimType = TypeOfClaim.Theft;
                    errorCheck         = false;
                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("\nYour selection was invalid. Please enter 1, 2, or 3.");
                    Console.ResetColor();
                    break;
                }
            }

            Console.WriteLine("\nEnter the claim description:");
            newClaim.Description = Console.ReadLine();

            Console.WriteLine("\nEnter the dollar amount of the claim:");
            newClaim.ClaimAmount = double.Parse(Console.ReadLine());

            Console.WriteLine("\nWhat date did the incident occur? Format: MM/DD/YYYY");
            newClaim.DateOfIncident = DateTime.Parse(Console.ReadLine());

            Console.WriteLine("\nToday's date will automatically be used for the Date of Claim.");
            newClaim.DateOfClaim = DateTime.Now.Date;

            if (newClaim.IsValid == true)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"\nThis claim is valid.");
                Console.ResetColor();
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\nThis claim is not valid.");
                Console.ResetColor();
            }

            _claimRepo.CreateANewClaimToQueue(newClaim);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine($"\nThis claim has been added to the queue.");
            Console.ResetColor();
            Console.ReadLine();
        }