예제 #1
0
        public void AddOutingToRepoTest()
        {
            Outing     outing = new Outing(Outing.TypeOfOuting.Golf, 16, new DateTime(2019, 7, 10), 3000);
            OutingRepo repo   = new OutingRepo();

            Console.WriteLine(repo._outingRepo.Count);
            repo.AddOutingToRepo(outing);
            Console.WriteLine(repo._outingRepo.Count);
            Assert.AreEqual(1, repo._outingRepo.Count);
            Console.WriteLine(repo._outingRepo[0].OutingType);
        }
예제 #2
0
        public void GetAllOutingsTest()
        {
            Outing     outing = new Outing(Outing.TypeOfOuting.Golf, 16, new DateTime(2019, 7, 10), 3000);
            OutingRepo repo   = new OutingRepo();

            repo.AddOutingToRepo(outing);
            Outing outingTwo = new Outing(Outing.TypeOfOuting.Bowling, 10, new DateTime(2019, 10, 31), 500);

            repo.AddOutingToRepo(outing);
            Console.WriteLine(repo.GetAllOutings()[1].OutingAttendance);
            Assert.AreEqual(2, repo.GetAllOutings().Count);
        }
예제 #3
0
        public void AddToListTest()
        {
            OutingRepo           outingRepo = new OutingRepo();
            List <OutingContent> outingList = outingRepo.GetOutingList();

            OutingContent content = new OutingContent(OutingType.Concert, 10, DateTime.Today, 10m);

            int expected = 1;

            outingRepo.AddToList(content);

            Assert.AreEqual(expected, outingList.Count);
        }
        public void CostAllEvent_Test()
        {
            Outing     outing      = new Outing(Event.Golf, 2, DateTime.Now, 10, 200);
            Outing     outingTwo   = new Outing(Event.Golf, 3, DateTime.Now, 15, 600);
            Outing     outingThree = new Outing(Event.Concert, 10, DateTime.Now, 20, 2000);
            OutingRepo repo        = new OutingRepo();

            repo.AddOuting(outing);
            repo.AddOuting(outingTwo);
            repo.AddOuting(outingThree);
            decimal amount   = repo.CostEvent();
            decimal actual   = amount;
            decimal expected = 2800;

            Assert.AreEqual(actual, expected);
        }
예제 #5
0
        public void AddCostShouldReturnCorrectValue()
        {
            OutingRepo _outingRepo = new OutingRepo();
            OutingInfo outing      = new OutingInfo(OutingType.Golf, 10, "03/01/18", 20.00m, 200.00m);
            OutingInfo outingTwo   = new OutingInfo(OutingType.Golf, 10, "03/01/18", 20.00m, 200.00m);
            OutingInfo outingThree = new OutingInfo(OutingType.Golf, 10, "03/01/18", 20.00m, 200.00m);

            _outingRepo.AddOutingToList(outing);
            _outingRepo.AddOutingToList(outingTwo);
            _outingRepo.AddOutingToList(outingThree);

            decimal actual   = _outingRepo.AddCostofOneType(OutingType.Golf);
            decimal expected = 600m;

            Assert.AreEqual(expected, actual);
        }
예제 #6
0
        public void AddOutingsShouldReturnCorrectCount()
        {   //Arrange
            OutingRepo _outingRepo = new OutingRepo();
            OutingInfo outing      = new OutingInfo();
            OutingInfo outingTwo   = new OutingInfo();
            OutingInfo outingThree = new OutingInfo();

            _outingRepo.AddOutingToList(outing);
            _outingRepo.AddOutingToList(outingTwo);
            _outingRepo.AddOutingToList(outingThree);
            //Act
            int actual   = _outingRepo.GetOutingInfo().Count;
            int expected = 3;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void AddGetList_Test()
        {
            //Arrange
            Outing     outing      = new Outing();
            Outing     outingTwo   = new Outing(Event.Concert, 10, DateTime.Now, 20, 2000);
            Outing     outingThree = new Outing(Event.Golf, 2, DateTime.Now, 10, 200);
            OutingRepo repo        = new OutingRepo();

            //Act
            repo.AddOuting(outing);
            repo.AddOuting(outingTwo);
            repo.AddOuting(outingThree);

            int actual   = repo.GetOutings().Count();
            int expected = 3;

            //Assert
            Assert.AreEqual(actual, expected);
        }
예제 #8
0
        public void CombineCostAllTest()
        {
            OutingRepo    outingRepo = new OutingRepo();
            OutingContent content    = new OutingContent();

            content.CostForEvent = 100m;

            OutingContent contentOne = new OutingContent();

            contentOne.CostForEvent = 100m;

            outingRepo.AddToList(content);
            outingRepo.AddToList(contentOne);
            decimal expected = 200m;

            decimal actual = outingRepo.CombinedCostOfAllOutingsGet();

            Assert.AreEqual(expected, actual);
        }
예제 #9
0
        public void CombinedCostAmusementParkTest()
        {
            OutingRepo    outingRepo = new OutingRepo();
            OutingContent content    = new OutingContent();

            content.CostForEvent = 100m;
            content.Type         = OutingType.AmusementPark;

            OutingContent contentOne = new OutingContent();

            contentOne.CostForEvent = 100m;
            contentOne.Type         = OutingType.AmusementPark;

            outingRepo.AddToList(content);
            outingRepo.AddToList(contentOne);
            decimal expected = 200m;
            decimal actual   = outingRepo.CombinedTypeCostAmusementParks();

            Assert.AreEqual(expected, actual);
        }
예제 #10
0
        static void Main(string[] args)
        {
            string     userInput;
            OutingRepo repo = new OutingRepo();

            do
            {
                Console.WriteLine("Please choose a menu item\n" +
                                  "1. Display a list of all outings\n" +
                                  "2. Add outing\n" +
                                  "3. Cost Statistics\n" +
                                  "4. Exit");
                userInput = Console.ReadLine();
                switch (userInput)
                {
                case "1":
                    Console.Clear();
                    repo.DisplayAll();
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                    Console.Clear();
                    break;

                case "2":
                    Console.Clear();
                    Console.WriteLine("Please enter the event type (Golf, Bowling, Amusement Park, Concert)");
                    string        eventSTR;
                    Outing.Events events = Outing.Events.Golf;
                    do
                    {
                        eventSTR = Console.ReadLine().ToLower().Replace(" ", "");
                        switch (eventSTR)
                        {
                        case "golf":
                            events = Outing.Events.Golf;
                            break;

                        case "bowling":
                            events = Outing.Events.Bowling;
                            break;

                        case "amusementpark":
                            events = Outing.Events.AmusementPark;
                            break;

                        case "concert":
                            events = Outing.Events.Concert;
                            break;

                        default:
                            Console.WriteLine("Please enter one of the options");
                            break;
                        }
                    } while (eventSTR != "golf" && eventSTR != "bowling" && eventSTR != "amusementpark" && eventSTR != "concert");
                    Console.Clear();
                    Console.WriteLine("Please enter the number of people that attended");
                    int  numberAttended;
                    bool isNumber;
                    do
                    {
                        if (int.TryParse(Console.ReadLine(), out numberAttended))
                        {
                            isNumber = true;
                        }
                        else
                        {
                            Console.WriteLine("Please enter a whole number");
                            isNumber = false;
                        }
                    } while (!isNumber);
                    Console.Clear();
                    Console.WriteLine("Please enter the date of the event (Format MM/DD/YY)");
                    DateTime date;
                    bool     isDate;
                    do
                    {
                        if (DateTime.TryParse(Console.ReadLine(), out date))
                        {
                            isDate = true;
                        }
                        else
                        {
                            Console.WriteLine("Please enter a date with the correct format");
                            isDate = false;
                        }
                    } while (!isDate);
                    Console.Clear();
                    Console.WriteLine("Please enter the cost per person for the event.");
                    decimal costPerPerson;
                    bool    isCost;
                    do
                    {
                        string costSTR = Console.ReadLine().Replace("$", "");
                        decimal.TryParse(costSTR, out costPerPerson);
                        if (decimal.Round(costPerPerson, 2) != costPerPerson || costSTR != Convert.ToString(costPerPerson))
                        {
                            Console.WriteLine("Please enter a valid number");
                            isCost = false;
                        }
                        else
                        {
                            isCost = true;
                        }
                    } while (!isCost);
                    Console.Clear();
                    Outing outing = new Outing(events, numberAttended, date, costPerPerson);
                    repo.AddOuting(outing);
                    Console.WriteLine("Outing added.\n" +
                                      "Press any key to continue...");
                    Console.ReadKey();
                    Console.Clear();
                    break;

                case "3":
                    Console.Clear();
                    repo.CombinedCosts();
                    Console.WriteLine("Press any key to continue...");
                    Console.ReadKey();
                    Console.Clear();
                    break;

                case "4":
                    break;

                default:
                    Console.WriteLine("Please choose a number between 1-4");
                    break;
                }
            } while (userInput != "4");
        }