Beispiel #1
0
        public void AddOutingShouldAddNewOutingToList()
        {
            // Arrange
            OutingsRepo repo   = new OutingsRepo();
            Outings     outing = new Outings(TypeOfEvent.Golf, 100, DateTime.Now, 50, 5000);

            // Act
            repo.AddOuting(outing);
            int expected = 1;

            // Assert
            int actual = repo.ListAllOutings().Count;

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void Run()
        {
            OutingsRepo repo    = new OutingsRepo();
            bool        running = true;
            UserHelper  helper  = new UserHelper();

            while (running)
            {
                int response = new int();

                Console.WriteLine("What would you like to do? \n" +
                                  "1. Add an outing \n" +
                                  "2. View total costs of a certain outing type \n" +
                                  "3. Exit");
                try
                {
                    response = Convert.ToInt32(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("Please select an option provided.");
                }

                switch (response)
                {
                case 1:
                    var add = helper.GetOutingToAdd();
                    repo.AddOuting(add);
                    break;

                case 2:
                    var type = helper.GetTypeForCost();
                    repo.TotalCostByType(type);
                    break;

                case 3:
                    running = false;
                    Environment.Exit(0);
                    break;

                default:
                    Console.WriteLine("Please select a valid option.");
                    break;
                }
            }
        }
Beispiel #3
0
        public void TotalCostShouldReturnTotalOfAllOutings()
        {
            // Arange
            OutingsRepo repo    = new OutingsRepo();
            Outings     outing1 = new Outings(TypeOfEvent.Golf, 50, DateTime.Now, 100, 5000);
            Outings     outing2 = new Outings(TypeOfEvent.Golf, 50, DateTime.Now, 300, 15000);

            repo.AddOuting(outing1);
            repo.AddOuting(outing2);

            // Act
            double expected  = 20000;
            double totalCost = repo.TotalOutingsCost();

            // Assert
            Assert.AreEqual(expected, totalCost);
        }
Beispiel #4
0
        public void TotalCostByTypeShouldReturnTotalCostByGivenType()
        {
            // Arange
            OutingsRepo repo    = new OutingsRepo();
            Outings     outing1 = new Outings(TypeOfEvent.Golf, 50, DateTime.Now, 100, 5000);
            Outings     outing2 = new Outings(TypeOfEvent.Bowling, 50, DateTime.Now, 300, 15000);
            Outings     outing3 = new Outings(TypeOfEvent.Golf, 50, DateTime.Now, 100, 5000);

            repo.AddOuting(outing1);
            repo.AddOuting(outing2);
            repo.AddOuting(outing3);

            // Act
            double expectedGolf     = 10000;
            double expectedBowling  = 15000;
            double totalCostGolf    = repo.TotalCostByType(TypeOfEvent.Golf);
            double totalCostBowling = repo.TotalCostByType(TypeOfEvent.Bowling);

            // Assert
            Assert.AreEqual(expectedGolf, totalCostGolf);
            Assert.AreEqual(expectedBowling, totalCostBowling);
        }