示例#1
0
        // Take care of the next claim
        private void DisplayNextClaim()
        {
            Console.Clear();
            // Get next item in list
            Claim claim = _claimRepo._claims.First();

            // Display claim
            Console.WriteLine($"ClaimId: {claim.ClaimId}\n" + $"Type: {claim.ClaimType}\n" + $"Description: {claim.Description}\n" + $"DateOfAccident: {claim.DateofIncident}\n" + $"DateOfClaim: {claim.DateOfClaim}\n" + $"IsValid: {claim.IsValid}\n");

            // Query the user
            Console.WriteLine("Do you want to deal with this claim now(y/n)?");
            bool keepRunning = true;

            while (keepRunning)
            {
                string input = Console.ReadLine();
                if (input == "y")
                {
                    _claimRepo.RemoveClaimFromTopOfQueue();
                    keepRunning = false;
                }
                else if (input == "n")
                {
                    _claimRepo.RemoveClaimFromTopOfQueue();
                    _claimRepo.AddClaim(claim);
                    keepRunning = false;
                }
                else
                {
                    Console.WriteLine("Please enter y or n");
                }
            }
        }
        private void AddNewClaim()
        {
            Console.Clear();
            ClaimContent newClaim = new ClaimContent();

            Console.WriteLine("Enter Claim ID:");
            string idOfClaim    = Console.ReadLine();
            int    newIDOfClaim = int.Parse(idOfClaim);

            newClaim.ClaimID = newIDOfClaim;

            Console.WriteLine("Enter claim type: (Enter NUMBER)\n" +
                              "1. Car\n" +
                              "2. Home\n" +
                              "3. Theft");
            string typeOfClaim = Console.ReadLine();
            int    intOfClaim  = int.Parse(typeOfClaim);

            newClaim.ClaimType = (TypesOfClaims)intOfClaim;

            Console.WriteLine("Enter a claim description: ");
            string claimDesc = Console.ReadLine();

            newClaim.Description = claimDesc;

            Console.WriteLine("Amount of Damage: ");
            string claimCost    = Console.ReadLine();
            double costAsDouble = double.Parse(claimCost);

            newClaim.ClaimAmount = costAsDouble;

            Console.WriteLine("Date of Accident:");
            string   dateOfAcc  = Console.ReadLine();
            DateTime dateAsDate = DateTime.Parse(dateOfAcc);

            newClaim.DateOfIncident = dateAsDate;

            Console.WriteLine("Date of Claim:");
            string   dateOfClaim     = Console.ReadLine();
            DateTime claimDateAsDate = DateTime.Parse(dateOfClaim);

            newClaim.DateOfClaim = claimDateAsDate;

            Console.WriteLine("Is this claim valid? (y/n)");
            string validate = Console.ReadLine().Trim().ToLower();

            if (validate == "y")
            {
                newClaim.IsValid = true;
            }
            else
            {
                newClaim.IsValid = false;
            }

            _claimRepo.AddClaim(newClaim);
        }
示例#3
0
        public void AddClaimTest()
        {
            //Arrange
            Claim newClaim = new Claim(2, ClaimType.Theft, "PS5 stolen from house by ex-husband", 500.00, new DateTime(2020, 12, 20), new DateTime(2020 / 12 / 22), true, false);

            //Act
            bool wasAdded = _repo.AddClaim(newClaim);

            //Assert
            Assert.IsTrue(wasAdded);
        }
示例#4
0
        public void MyTestMethod()
        {
            Claim     test     = new Claim();
            Claim     test2    = new Claim();
            ClaimRepo testRepo = new ClaimRepo();

            testRepo.AddClaim(test);
            testRepo.AddClaim(test2);
            testRepo.HandleClaim();

            Assert.AreEqual(test2, testRepo.GetQueue().Peek());
        }
示例#5
0
        public void TestNextClaim_DesplaysNextClaimInList()
        {
            ClaimRepo repo = new ClaimRepo();

            repo.AddClaim(ID, claimType, description, amount, incident, claim);
            Assert.IsTrue(repo.ShowNextClaim());
        }
示例#6
0
        public void DefaultValues()
        {
            _repo    = new ClaimRepo();
            _content = new ClaimContent(1, TypesOfClaims.Car, "Crash", 4999, new DateTime(2020, 12, 9), new DateTime(2020, 12, 10), true);

            _repo.AddClaim(_content);
        }
示例#7
0
        public void TestAddClaimAndSeeClaims_AddClaimToListAndDisplay()
        {
            ClaimRepo repo = new ClaimRepo();

            repo.AddClaim(ID, claimType, description, amount, incident, claim);
            Assert.IsTrue(repo.SeeClaims());
        }
        //Add Claim
        public void AddClaim()
        {
            Console.Clear();
            Claim newClaim = new Claim();

            //ClaimID
            Console.WriteLine("What is the claim ID?");
            newClaim.ClaimID = Console.ReadLine();


            //ClaimType
            Console.WriteLine("What is the claim type? \n" +
                              "1. House\n" +
                              "2. Car \n" +
                              "3. Theft");
            newClaim.ClaimType = (TypeOfClaim)int.Parse(Console.ReadLine());
            //casting - taking one type and converting

            //Description
            Console.WriteLine("Claim description:");
            newClaim.Description = Console.ReadLine();


            //ClaimAmount
            Console.WriteLine("Claim Amount:");
            string newClaimAmmount = Console.ReadLine();
            double claimAmount     = double.Parse(newClaimAmmount);

            newClaim.ClaimAmount = (int)claimAmount;

            //Date Of Incident
            Console.WriteLine("Date of incident(YYYY, MM, DD):");
            string   incidentDate   = Console.ReadLine();
            DateTime dateOfIncident = Convert.ToDateTime(incidentDate);

            newClaim.DateOfIncident = (DateTime)dateOfIncident;


            //Date Of Claim
            Console.WriteLine("Date of claim (YYYY, MM, DD):");
            string   claimDate   = Console.ReadLine();
            DateTime dateOfClaim = Convert.ToDateTime(claimDate);

            newClaim.DateOfClaim = (DateTime)dateOfClaim;

            _claimRepo.AddClaim(newClaim);
        }
        public void AddClaimAddsClaim()
        {
            Claim     claim     = new Claim();
            ClaimRepo claimRepo = new ClaimRepo();
            bool      result    = claimRepo.AddClaim(claim);

            Assert.IsTrue(result);
        }
        public void AddItemShouldReturnTrue()
        {
            // Arrange
            Claim home = new Claim(TypeOfClaim.Home, "House fire in kitchen.", 4000, new DateTime(2018, 4, 11), new DateTime(2018, 4, 12));

            // Act/Assert
            Assert.IsTrue(_repo.AddClaim(home));
        }
示例#11
0
        public void TestRemoveClaim_RemovesTheFirstClaimInList()
        {
            ClaimRepo repo = new ClaimRepo();

            repo.AddClaim(ID, claimType, description, amount, incident, claim);
            repo.RemoveClaim();
            Assert.IsFalse(repo.SeeClaims());
        }
示例#12
0
        public void AddClaim_ShouldGetNotNull()
        {
            ClaimContent torres = new ClaimContent(1, TypesOfClaims.Car, "Car Accident on 465.", 400, new DateTime(2018, 4, 25), new DateTime(2018, 4, 27), true);

            _repo.AddClaim(torres);

            Assert.IsNotNull(torres);
        }
示例#13
0
        public void AddClaim_ShouldGetNotNull()
        {
            Claim     test     = new Claim();
            ClaimRepo testRepo = new ClaimRepo();

            testRepo.AddClaim(test);
            Claim fromRepo = testRepo.GetQueue().Peek();

            Assert.IsNotNull(fromRepo);
        }
        public void HandleClaimRemovesClaimFromDB()
        {
            Claim     claim     = new Claim();
            ClaimRepo claimRepo = new ClaimRepo();

            claimRepo.AddClaim(claim);
            bool isHandled = claimRepo.HandleClaim(claim);

            Assert.IsTrue(isHandled);
        }
        public void GetClaimsGetsAllClaims()
        {
            Claim     claim     = new Claim();
            ClaimRepo claimRepo = new ClaimRepo();

            claimRepo.AddClaim(claim);
            List <Claim> claimList    = claimRepo.GetClaims();
            bool         listNotEmpty = claimList.Contains(claim);

            Assert.IsTrue(listNotEmpty);
        }
示例#16
0
        public void GetClaimList()
        {
            ClaimProp content = new ClaimProp();
            ClaimRepo repo    = new ClaimRepo();

            repo.AddClaim(content);
            List <ClaimProp> contents = repo.ViewClaim();

            bool directoryHadContent = contents.Contains(content);

            Assert.IsTrue(directoryHadContent);
        }
示例#17
0
        public void AddClaim_AreEqual()
        {
            // Arrange
            Claims    claimId = new Claims(1);
            ClaimRepo repo    = new ClaimRepo();
            SortedDictionary <int, Claims> _repo = repo.GetAllClaims();


            // Act
            repo.AddClaim(claimId);
            int number = repo.GetAllClaims().Count;

            // Assert
            Assert.AreEqual(1, number);
        }
示例#18
0
        public void AddNewClaim()
        {
            Console.Clear();
            SortedDictionary <int, Claims> duplicateId = _claimRepo.GetAllClaims();

            Console.WriteLine("Enter the claim id:\n");
            int id = Convert.ToInt32(Console.ReadLine());

            if (duplicateId.ContainsKey(id))
            {
                Console.WriteLine($"Claim id: {id} is already existed. Please enter different claim id number.\nPress any key to continue...");
            }
            else
            {
                Console.WriteLine("Enter the claim type(Car, Home, Theft):\n");
                string type = Console.ReadLine();
                Console.WriteLine("Enter a claim description:\n");
                string description = Console.ReadLine();
                Console.WriteLine("Amount of Damage:\n");
                double amount = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine("Date Of Accident:\n");
                DateTime accidentDate = Convert.ToDateTime(Console.ReadLine());
                Console.WriteLine("Date of claim:\n");
                DateTime claimDate = Convert.ToDateTime(Console.ReadLine());
                Console.WriteLine("Is this claim valid?");
                bool   ans   = Convert.ToBoolean(Console.ReadLine());
                Claims claim = new Claims(id);
                claim.ClaimID        = id;
                claim.ClaimType      = type;
                claim.Description    = description;
                claim.ClaimAmount    = amount;
                claim.DateOfIncident = accidentDate;
                claim.DateOfClaim    = claimDate;
                claim.IsValid        = ans;

                _claimRepo.AddClaim(claim);
            }
        }
        public void AddNewClaim()
        {
            Console.Clear();
            Claim newClaim = new Claim();

            List <Claim> all = _repo.GetAllClaims();

            newClaim.ClaimID = all.Count + 1; // new Claim ID automatically set to next number

            Console.Write("Enter Claim Type (Car / Home / Theft):");
            string input = Console.ReadLine();

            if (input.ToLower() == "car")
            {
                newClaim.Type = ClaimType.Car;
            }
            else if (input.ToLower() == "home")
            {
                newClaim.Type = ClaimType.Home;
            }
            else if (input.ToLower() == "theft")
            {
                newClaim.Type = ClaimType.Theft;
            }
            else
            {
                Console.WriteLine("Not a valid claim type.");
            }

            Console.Write("Describe the claim:");
            newClaim.Desc = Console.ReadLine();

            Console.Write("Enter amount of damage in $:");
            string damage = Console.ReadLine();

            if (damage.Contains("$"))
            {
                newClaim.ClaimAmount = Convert.ToDouble(damage.Replace("$", ""));
            }
            else
            {
                newClaim.ClaimAmount = Convert.ToDouble(damage);
            }
            Console.Write("Enter date of incident (YYYY/MM/DD):");
            newClaim.DateOfIncident = Convert.ToDateTime(Console.ReadLine());

            Console.Write("Set Claim Date to today (YES / NO):");
            string toToday = Console.ReadLine();

            if (toToday.ToUpper() == "NO")
            {
                Console.Write("Enter date of claim (YYYY/MM/DD):");
                newClaim.DateOfClaim = Convert.ToDateTime(Console.ReadLine());
            }
            else
            {
                newClaim.DateOfClaim = DateTime.Today;
            }

            Console.Write("Is claim valid (YES / NO):");
            string validClaim = Console.ReadLine();

            if (validClaim.ToUpper() == "NO")
            {
                newClaim.IsValid = false;
            }
            else
            {
                newClaim.IsValid = true;
            }

            newClaim.Handled = false;
            _repo.AddClaim(newClaim);
        }
 public void Arrange()
 {
     _repo  = new ClaimRepo();
     _claim = new Claim(TypeOfClaim.Car, "Car Accident on 465.", 400, new DateTime(2018, 4, 25), new DateTime(2018, 4, 27));
     _repo.AddClaim(_claim);
 }
示例#21
0
        private void NewClaim()
        {
            Console.Clear();

            Console.WriteLine("Enter the claim ID: ");
            String id = Console.ReadLine();

            Console.WriteLine("\nEnter the claim type (Car, Home, or Theft): ");
            String    typeAsString = Console.ReadLine();
            ClaimType type         = ClaimType.Car;
            bool      isValid      = false;

            while (isValid == false)
            {
                if (typeAsString.ToLower() == "car")
                {
                    type    = ClaimType.Car;
                    isValid = true;
                }
                else if (typeAsString.ToLower() == "home")
                {
                    type    = ClaimType.Home;
                    isValid = true;
                }
                else if (typeAsString.ToLower() == "theft")
                {
                    type    = ClaimType.Theft;
                    isValid = true;
                }
                else
                {
                    Console.WriteLine("Please enter a valid option (Car, Home, Theft): ");
                    typeAsString = Console.ReadLine();
                }
            }

            Console.WriteLine("\nEnter a claim description: ");
            String description = Console.ReadLine();

            Console.WriteLine("\nAmount of Damage: ");
            decimal damage = decimal.Parse(Console.ReadLine());

            Console.WriteLine("\nDate of incident: ");
            DateTime incident = DateTime.Parse(Console.ReadLine());

            Console.WriteLine("\nDate of claim: ");
            DateTime claim = DateTime.Parse(Console.ReadLine());

            Claim newClaim = new Claim(id, type, description, damage, incident, claim);

            if (newClaim.IsValid == true)
            {
                Console.WriteLine("\nThis claim is valid.");
            }
            else
            {
                Console.WriteLine("\nThis claim is not valid.");
            }

            _claimRepo.AddClaim(newClaim);

            Console.WriteLine("\nPress any key to continue...");
            Console.ReadKey();
        }
示例#22
0
        static void Main(string[] args)
        {
            ClaimRepo repo = new ClaimRepo();
            string    userInput;
            string    claimInput;
            string    claimTypeSTR;
            bool      validClaimType;
            bool      validDamageNumber;
            bool      successfulAccident;
            bool      successfulClaim;
            DateTime  accidentDate;
            DateTime  claimDate;

            do
            {
                Console.Clear();
                Console.WriteLine("Choose a menu item:\n" +
                                  "1. See all claims\n" +
                                  "2. Take care of next claim\n" +
                                  "3. Enter a new claim\n" +
                                  "4. Exit");
                userInput = Console.ReadLine();
                switch (userInput)
                {
                case "1":
                    Console.Clear();
                    if (repo.SeeClaims())
                    {
                        Console.WriteLine();
                        Console.WriteLine("Press any key to continue");
                        Console.ReadKey();
                        break;
                    }
                    else
                    {
                        Console.WriteLine("There are no claims. Press any key to continue");
                        Console.ReadKey();
                        Console.Clear();
                    }
                    break;

                case "2":
                    Console.Clear();
                    if (repo.ShowNextClaim())
                    {
                        do
                        {
                            Console.WriteLine("Do you want to deal with this claim now(y/n)?");
                            claimInput = Console.ReadLine().ToLower();
                            switch (claimInput)
                            {
                            case "y":
                                repo.RemoveClaim();
                                break;

                            case "n":
                                break;

                            default:
                                Console.WriteLine("Please enter y or n");
                                break;
                            }
                        } while (claimInput != "n" && claimInput != "y");
                    }
                    else
                    {
                        Console.WriteLine("There are no claims. Press any key to continue");
                        Console.ReadKey();
                        Console.Clear();
                    }
                    break;

                case "3":
                    Console.Clear();
                    Console.WriteLine("Please enter the ClaimID");
                    string claimID = Console.ReadLine();
                    Console.Clear();
                    Console.WriteLine("Please enter the claim type: Car, Home, or Theft");
                    ChallengeTwoRepo.Claim.ClaimTypes claimType = ChallengeTwoRepo.Claim.ClaimTypes.Car;
                    do
                    {
                        claimTypeSTR = Console.ReadLine().ToLower();
                        switch (claimTypeSTR)
                        {
                        case "car":
                            claimType      = ChallengeTwoRepo.Claim.ClaimTypes.Car;
                            validClaimType = true;
                            break;

                        case "home":
                            claimType      = ChallengeTwoRepo.Claim.ClaimTypes.Home;
                            validClaimType = true;
                            break;

                        case "theft":
                            claimType      = ChallengeTwoRepo.Claim.ClaimTypes.Theft;
                            validClaimType = true;
                            break;

                        default:
                            Console.WriteLine("Please enter Car, Home, or Theft");
                            validClaimType = false;
                            break;
                        }
                    } while (!validClaimType);
                    Console.Clear();
                    Console.WriteLine("Please enter a claim description");
                    string description = Console.ReadLine();
                    Console.Clear();
                    Console.WriteLine("Please enter the amount of Damage");
                    string damage;
                    do
                    {
                        damage = Console.ReadLine().Replace("$", "");
                        decimal decimalCheck;
                        decimal.TryParse(damage, out decimalCheck);
                        if (decimal.Round(decimalCheck, 2) != decimalCheck || damage != Convert.ToString(decimalCheck))
                        {
                            Console.WriteLine("Please enter a valid number");
                            validDamageNumber = false;
                        }
                        else
                        {
                            validDamageNumber = true;
                        }
                    } while (!validDamageNumber);
                    Console.Clear();
                    Console.WriteLine("Please enter the date of the accident. Format MM/DD/YY");
                    do
                    {
                        string accidentDateSTR = Console.ReadLine();
                        successfulAccident = DateTime.TryParse(accidentDateSTR, out accidentDate);
                        if (successfulAccident)
                        {
                            continue;
                        }
                        else
                        {
                            Console.WriteLine("Please enter a valid date");
                        }
                    } while (!successfulAccident);
                    Console.Clear();
                    Console.WriteLine("Please enter the date of the claim. Format MM/DD/YY");
                    do
                    {
                        string claimDateSTR = Console.ReadLine();
                        successfulClaim = DateTime.TryParse(claimDateSTR, out claimDate);
                        if (successfulClaim)
                        {
                            continue;
                        }
                        else
                        {
                            Console.WriteLine("Please enter a valid date");
                        }
                    } while (!successfulAccident);
                    Console.Clear();
                    repo.AddClaim(claimID, claimType, description, damage, accidentDate, claimDate);
                    ChallengeTwoRepo.Claim preview = new ChallengeTwoRepo.Claim(claimID, claimType, description, damage, accidentDate, claimDate);
                    Console.WriteLine($"ClaimID: {preview.ClaimID}\n" +
                                      $"Type: {preview.ClaimType}\n" +
                                      $"Amount: ${double.Parse(preview.ClaimAmount).ToString("F")}\n" +
                                      $"DateOfAccident: {preview.DateOfIncident.ToShortDateString()}\n" +
                                      $"DateOfClaim: {preview.DateOfClaim.ToShortDateString()}");
                    if (preview.IsValid)
                    {
                        Console.WriteLine("This claim is valid.");
                    }
                    else
                    {
                        Console.WriteLine("This claim is not valid");
                    }
                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    break;

                case "4":
                    break;

                default:
                    Console.WriteLine("Please enter a number betwen 1-4");
                    break;
                }
            } while (userInput != "4");
        }
示例#23
0
        public void AddNewClaim()
        {
            Console.Clear();
            Claim newClaim = new Claim();

            Console.Write("Enter Claim Id: ");
            int claimId = Convert.ToInt32(Console.ReadLine());

            newClaim.ClaimId = claimId;

            Console.Write("Enter Claim Type(Car, Home, Theft): ");
            string claimType = Console.ReadLine();

            switch (claimType.ToLower())
            {
            case "car":
                newClaim.Type = ClaimType.Car;
                break;

            case "home":
                newClaim.Type = ClaimType.Home;
                break;

            case "theft":
                newClaim.Type = ClaimType.Theft;
                break;

            default:
                Console.WriteLine("Enter valid claim type of Car, Home, or Theft. Learn to read dummy.");
                break;
            }

            Console.Write("Describe the claim: ");
            string claimDesc = Console.ReadLine();

            newClaim.Desc = claimDesc;

            Console.Write("Enter claim damage amount(DO NOT ENTER $): ");
            string claimAmount = Console.ReadLine();

            if (claimAmount.Contains("$"))
            {
                claimAmount          = claimAmount.Replace("$", string.Empty);
                newClaim.ClaimAmount = Convert.ToDouble(claimAmount);
            }
            else
            {
                newClaim.ClaimAmount = Convert.ToDouble(claimAmount);
            }

            Console.Write("Enter date of incident(yyyy/mm/dd): ");
            newClaim.DateOfIncident = Convert.ToDateTime(Console.ReadLine());

            Console.Write("Set claim date to today(Yes or No): ");
            string claimToday = Console.ReadLine();

            if (claimToday.ToLower() == "no")
            {
                Console.Write("Enter date of claim(yyyy/mm/dd): ");
                newClaim.DateOfClaim = Convert.ToDateTime(Console.ReadLine());
            }
            else if (claimToday.ToLower() == "yes")
            {
                newClaim.DateOfClaim = DateTime.Today;
            }
            else
            {
                Console.WriteLine("Please enter Yes or No");
            }

            TimeSpan sinceIncident = newClaim.DateOfClaim - newClaim.DateOfIncident;

            if (sinceIncident.Days > 30)
            {
                Console.Write($"{sinceIncident} Days have passed since incident. This claim is not valid.");
                newClaim.IsValid = false;
            }
            else
            {
                Console.WriteLine($"{sinceIncident} days have passed since incident. Is this a vaild claim(Yes or No): ");
                string claimValid = Console.ReadLine();
                if (claimValid.ToLower() == "no")
                {
                    newClaim.IsValid = false;
                }
                else if (claimValid.ToLower() == "yes")
                {
                    newClaim.IsValid = true;
                }
                else
                {
                    Console.WriteLine("Please enter Yes or No");
                }
                newClaim.Handled = false;
                _repo.AddClaim(newClaim);
            }
        }