Esempio n. 1
0
 public void TestThatUserHasFrequentFlierMilesAfterBooking2()
 {
     var target = new User("Bob Dole");
     target.book(new Flight(StartDate, EndDate, 1), new Hotel(5), new Car(3));
     Assert.Less(0, target.FrequentFlierMiles);
     Assert.AreEqual(3, target.Bookings.Count);
 }
Esempio n. 2
0
        public void TestThatHotelNotEqualToNonHotel()
        {
            var hot1 = new Hotel(4);
            var notHotel = new User("I'm not a hotel");

            Assert.False(hot1.Equals(notHotel));
        }
Esempio n. 3
0
 public void TestThatUserDoesRemoveCarFromServiceLocatorWhenBooked()
 {
     ServiceLocator serviceLocator = new ServiceLocator();
     var carToBook = new Car(5);
     var remainingCar = new Car(7);
     serviceLocator.AddCar(carToBook);
     serviceLocator.AddCar(remainingCar);
     typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);
     var target = new User("Bob");
     target.book(carToBook);
     Assert.AreEqual(1, ServiceLocator.Instance.AvailableCars.Count);
     Assert.AreSame(remainingCar, ServiceLocator.Instance.AvailableCars[0]);
 }
Esempio n. 4
0
 public void TestThatUserDoesRemovveFlightFromServiceLocatorWhenBooked()
 {
     ServiceLocator serviceLocator = new ServiceLocator();
     var flightToBook = new Flight(new DateTime(2009, 11, 1), new DateTime(2009, 11, 30), 750);
     var remainingFlight = new Flight(new DateTime(2009, 11, 2), new DateTime(2009, 11, 28), 500);
     serviceLocator.AddFlight(flightToBook);
     serviceLocator.AddFlight(remainingFlight);
     typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);
     var target = new User("Bob");
     target.book(flightToBook);
     Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
     Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
 }
Esempio n. 5
0
 public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
 {
     ServiceLocator serviceLocator = new ServiceLocator();
     var flightToBook = new Flight(DateTime.Now, DateTime.Now.AddDays(5), 0);
     var otherFlight = new Flight(DateTime.Now, DateTime.Now.AddDays(10), 0);
     serviceLocator.AddFlight(flightToBook);
     serviceLocator.AddFlight(otherFlight);
     typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)
     .SetValue(serviceLocator, serviceLocator);
     var target = new User("Bob");
     target.book(flightToBook);
     Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
     Assert.AreSame(otherFlight, ServiceLocator.Instance.AvailableFlights[0]);
 }
Esempio n. 6
0
 public void TestThatFlightIsRemovedFromServiceLocator()
 {
     ServiceLocator serviceLocator = new ServiceLocator();
     var flightToBook = ObjectMother.FlightToChicago();
     var remainingFlight = ObjectMother.FlightToChicago();
     serviceLocator = new ServiceLocator();
     serviceLocator.AddFlight(flightToBook);
     serviceLocator.AddFlight(remainingFlight);
     typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)
     .SetValue(serviceLocator, serviceLocator);
     var target = new User("Bob");
     target.book(flightToBook);
     Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
     Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
 }
Esempio n. 7
0
        public void TestThatUserDoesRemoveFlightFromSerivceLocatorWhenBooked()
        {
            ServiceLocator serviceloc = new ServiceLocator();
            var flightToBook = new Flight(new DateTime(2009, 11, 1), new DateTime(2009, 11, 30), 100);
            var remainingFlight = new Flight(new DateTime(2009, 12, 1), new DateTime(2009, 12, 30), 1000);
            serviceloc.AddFlight(flightToBook);
            serviceloc.AddFlight(remainingFlight);

            typeof(ServiceLocator).GetField("_instance", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic).SetValue(serviceloc, serviceloc);

            var target = new User("Bobby");
            target.book(flightToBook);

            Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
            Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
        }
Esempio n. 8
0
        public void TestThatServiceLocatorRemovesFlightWhenBooked()
        {
            ServiceLocator serviceLocator = new ServiceLocator();
            var flightToBook = new Flight(new DateTime(2000, 01, 01), new DateTime(2000, 01, 07), 5);
            var remainingFlight = new Flight(new DateTime(2000,01,01), new DateTime(2000,01,07), 6);
            serviceLocator.AddFlight(flightToBook);
            serviceLocator.AddFlight(remainingFlight);

            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)
            .SetValue(serviceLocator, serviceLocator);

            var target = new User("Jimbo");
            target.book(flightToBook);
            Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
            Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
        }
Esempio n. 9
0
        public void TestThatUserDoesRemoveFlightsWhichAreBookedFromListOfAvailableFlightsInServiceLocatorSinceBookedFlightsHaveNoMoreRoomOnThemForOtherPeopleToBuyTicketsToFlyOnThem()
        {
            ServiceLocator serviceLocator = new ServiceLocator();
            var flightToBook = new Flight(new DateTime(2011, 4, 15), new DateTime(2011, 4, 20), 1000);
            var remainingFlight = new Flight(new DateTime(2011, 4, 5), new DateTime(2011, 4, 10), 1000);
            serviceLocator.AddFlight(flightToBook);
            serviceLocator.AddFlight(remainingFlight);

            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);

            var target = new User("Bob");
            target.book(flightToBook);

            Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
            Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
        }
Esempio n. 10
0
        public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
        {
            ServiceLocator serviceLocator = new ServiceLocator();
            var flightToBook = new Flight(DateTime.Now, DateTime.Now.AddDays(5), 1000);
            var remainingFlight1 = new Flight(DateTime.Now.AddDays(2), DateTime.Now.AddDays(15), 1300);
            var remainingFlight2 = new Flight(DateTime.Now.AddDays(5), DateTime.Now.AddDays(18), 700);
            serviceLocator.AddFlight(flightToBook);
            serviceLocator.AddFlight(remainingFlight1);
            serviceLocator.AddFlight(remainingFlight2);

            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);

            var target = new User("Shawn");
            target.book(flightToBook);

            Assert.AreEqual(2, ServiceLocator.Instance.AvailableFlights.Count);
              			Assert.AreSame(remainingFlight1, ServiceLocator.Instance.AvailableFlights[0]);
            Assert.AreSame(remainingFlight2, ServiceLocator.Instance.AvailableFlights[1]);
        }
Esempio n. 11
0
        public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
        {
            ServiceLocator serviceLocator = new ServiceLocator();
            DateTime startDate1 = new DateTime(2012, 11, 1);
            DateTime endDate1 = new DateTime(2012, 11, 4);

            DateTime startDate2 = new DateTime(2013, 5, 12);
            DateTime endDate2 = new DateTime(2013, 5, 28);

            var flightToBook = new Flight(startDate1, endDate1, 5000);
            var remainingFlight= new Flight(startDate2, endDate2, 8000);
            serviceLocator.AddFlight(flightToBook);
            serviceLocator.AddFlight(remainingFlight);

            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);

            var target = new User("Bob");
            target.book(flightToBook);

            Assert.AreEqual(serviceLocator.AvailableFlights.Count, 1);
            Assert.AreSame(remainingFlight, serviceLocator.AvailableFlights[0]);
        }
Esempio n. 12
0
        public void TestThatTwoFlightsNotEqual()
        {
            var start = new DateTime(1999, 1, 1);
            var end = new DateTime(1999, 1, 2);
            int miles = 100;
            var flight = new Flight(start, end, miles);

            //var start1 = new DateTime(1999, 1, 1);
            //var end1 = new DateTime(1999, 1, 4);
            //int miles1 = 200;
            var notFlight = new User("NotAFlight");

            Assert.False(flight.Equals(notFlight));
        }
Esempio n. 13
0
 public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
 {
     ServiceLocator serviceLocator = new ServiceLocator();
     var flighttoBook = new Flight(StartDate, EndDate, 12);
     var flightRemaining = new Flight(StartDate, new DateTime(2010, 12, 12), 16);
     serviceLocator.AddFlight(flighttoBook);
     serviceLocator.AddFlight(flightRemaining);
     typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)
     .SetValue(serviceLocator, serviceLocator);
     var target = new User("Bob");
     target.book(flighttoBook);
     Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
     Assert.AreSame(flightRemaining, ServiceLocator.Instance.AvailableFlights[0]);
 }
Esempio n. 14
0
        public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
        {
            ServiceLocator serviceLocator = new ServiceLocator();

            var flightToBook = ObjectMother.CoupleOfDaysFlight();
            var remainingFlight = ObjectMother.LotsOfDaysFlight();
            serviceLocator.AddFlight(flightToBook);
            serviceLocator.AddFlight(remainingFlight);

            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);

            var target = new User("Alice");
            target.book(flightToBook);

            Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
            Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
        }
Esempio n. 15
0
        public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
        {
            ServiceLocator serviceLocator = new ServiceLocator();
            DateTime startDate = new DateTime();
            DateTime endDate = startDate;

            var flightToBook = new Flight(startDate, endDate, 10);
            var remainingFlight = new Flight(startDate, endDate, 10);

            serviceLocator.AddFlight(flightToBook);
            serviceLocator.AddFlight(remainingFlight);

            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);

            var target = new User("Bro");
            target.book(flightToBook);

            var availableFlights = ServiceLocator.Instance.AvailableFlights.Count;
            var flightRemaining = ServiceLocator.Instance.AvailableFlights[0];

            Assert.AreEqual(availableFlights, 1);
            Assert.AreSame(flightRemaining, remainingFlight);
        }
Esempio n. 16
0
 public void TestThatUserDoesRemoveCarFromServiceLocatorWhenBooked()
 {
     ServiceLocator serviceLocator = new ServiceLocator();
     var FlightToBook = new Flight(System.DateTime.MinValue, System.DateTime.MaxValue, 20);
     var remainingFlight = new Flight(System.DateTime.MinValue, System.DateTime.MaxValue, 15);
     serviceLocator.AddFlight(FlightToBook);
     serviceLocator.AddFlight(remainingFlight);
     typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)
     .SetValue(serviceLocator, serviceLocator);
     var target = new User("Bob");
     target.book(FlightToBook);
     Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
     Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
 }
Esempio n. 17
0
 public void TearDown()
 {
     target = null; // this is entirely unnecessary.. but I'm just showing a usage of the TearDown method here
 }
Esempio n. 18
0
        public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
        {
            System.DateTime arrive = new System.DateTime(13, 12, 10);
            System.DateTime depart = new System.DateTime(13, 12, 14);
            ServiceLocator serviceLocator = new ServiceLocator();
            var flightToBook = new Flight(arrive, depart, 4);
            var remainingFlight = new Flight(new System.DateTime(14, 11, 19),new System.DateTime(14, 11, 24),50);

            serviceLocator.AddFlight(flightToBook);
            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)
                .SetValue(serviceLocator, serviceLocator);
            serviceLocator.AddFlight(remainingFlight);
            var target = new User("Bob");
            target.book(flightToBook);

            Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
            Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
        }
Esempio n. 19
0
        public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
        {
            DateTime StartDate = new DateTime(2009, 11, 1);
            DateTime EndDate = new DateTime(2009, 11, 30);
            DateTime StartDate2 = new DateTime(2009, 5, 1);
            DateTime EndDate2 = new DateTime(2009, 5, 21);
            ServiceLocator serviceLocator = new ServiceLocator();
            var flightToBook = new Flight(StartDate, EndDate, 500);
            var remainingFlight = new Flight(StartDate2, EndDate2, 200);

            serviceLocator.AddFlight(flightToBook);
            serviceLocator.AddFlight(remainingFlight);

            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);

            var target = new User("Tom");
            target.book(flightToBook);

            Assert.AreEqual(serviceLocator.AvailableFlights.Count, 1);
            Assert.AreSame(serviceLocator.AvailableFlights[0], remainingFlight);
        }
Esempio n. 20
0
 public void Setup()
 {
     target = new User("Bob Dole");
 }
Esempio n. 21
0
        public void TestThatUserDoesRemoveFlightFromServiceLocatorWhenBooked()
        {
            ServiceLocator serviceLocator = new ServiceLocator();
            DateTime startDateForFirstFlight = new DateTime(2012, 03, 26);
            DateTime endDateForFirstFlight = new DateTime(2012, 05, 30);
            int milesForFirstFlight = 900;
            DateTime startDateForSecondFlight = new DateTime(2012, 07, 01);
            DateTime endDateForSecondFlight = new DateTime(2012, 07, 05);
            int milesForSecondFlight = 510;
            var flightToBook = new Flight(startDateForFirstFlight, endDateForFirstFlight, milesForFirstFlight);
            var remainingFlight = new Flight(startDateForSecondFlight, endDateForSecondFlight, milesForSecondFlight);
            serviceLocator.AddFlight(flightToBook);
            serviceLocator.AddFlight(remainingFlight);

            typeof(ServiceLocator).GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic).SetValue(serviceLocator, serviceLocator);

            var target = new User("Sriram");
            target.book(flightToBook);

            Assert.AreEqual(1, ServiceLocator.Instance.AvailableFlights.Count);
            Assert.AreSame(remainingFlight, ServiceLocator.Instance.AvailableFlights[0]);
        }
Esempio n. 22
0
 public void TestGreetingWithOver500000FFM()
 {
     User SupaFlyGuy = new User("Smith",500001);
     String greeting = SupaFlyGuy.customerGreeting();
     Assert.AreEqual("Hello Smith, we're SUPER excited to see you!", greeting);
 }
Esempio n. 23
0
 public void Setup()
 {
     target = new User("Bob Dole");
     target2 = new User("Bob Dole", 1000000);
 }