Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 public void AddOuting(Outings outing)
 {
     allOutings.Add(outing);
 }
Exemplo n.º 5
0
        public Outings GetOutingToAdd()
        {
            TypeOfEvent what       = TypeOfEvent.Unknown;
            int         guests     = -1;
            DateTime    date       = new DateTime();
            double      individual = -1;
            double      total      = -1;

            while (what == TypeOfEvent.Unknown)
            {
                Console.WriteLine("What type of event are you adding?\n" +
                                  "1. Golf\n" +
                                  "2. Bowling\n" +
                                  "3. Amusement Park\n" +
                                  "4. Concert");
                string t = Console.ReadLine();
                switch (t)
                {
                case "1":
                    what = TypeOfEvent.Golf;
                    break;

                case "2":
                    what = TypeOfEvent.Bowling;
                    break;

                case "3":
                    what = TypeOfEvent.AmusementPark;
                    break;

                case "4":
                    what = TypeOfEvent.Concert;
                    break;

                default:
                    Console.WriteLine("Please select a valid option.");
                    break;
                }
            }

            while (guests == -1)
            {
                Console.WriteLine("How many attendees were there?");
                string a = Console.ReadLine();
                try
                {
                    guests = Convert.ToInt32(a);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Please enter a valid number of individuals.");
                }
            }

            while (date == new DateTime())
            {
                Console.WriteLine("When did the event take place? (YYYY, MM, DD)");
                string d = Console.ReadLine();
                try
                {
                    date = Convert.ToDateTime(d);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Please enter a date in the given format.");
                }
            }

            while (individual == -1)
            {
                Console.WriteLine("What was the cost of an individual ticket?");
                try
                {
                    individual = Convert.ToDouble(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("Please enter a valid number");
                }
            }

            total = guests * individual;

            Outings outing = new Outings(what, guests, date, individual, total);

            Console.WriteLine($"Event: {what.ToString()} \n" +
                              $"Guests: {guests} \n" +
                              $"Date: {date.ToShortDateString()} \n" +
                              $"Ticket Cost: ${individual} \n" +
                              $"Total Cost: ${total}");
            Console.ReadLine();
            return(outing);
        }