예제 #1
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]);
 }
예제 #2
0
        public void TestThatServiceLocatorAvailableFlightsReturnsExpectedFlights()
        {
            var firstFlight = new Flight(DateTime.Today, DateTime.Today.AddDays(1), 500);
            var secondFlight = new Flight(DateTime.Today, DateTime.Today.AddDays(3), 200);
            var locator = new ServiceLocator();

            locator.AddFlight(firstFlight);
            locator.AddFlight(secondFlight);

            Assert.AreSame(firstFlight, locator.AvailableFlights[0]);
            Assert.AreSame(secondFlight, locator.AvailableFlights[1]);
            Assert.AreEqual(2, locator.AvailableFlights.Count);
        }
예제 #3
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]);
 }
예제 #4
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]);
 }
예제 #5
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]);
        }
예제 #6
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]);
        }
예제 #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]);
        }
예제 #8
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]);
        }
예제 #9
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]);
        }
예제 #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]);
        }
예제 #11
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);
        }
예제 #12
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]);
        }
예제 #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]);
 }
예제 #14
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);
        }
예제 #15
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]);
        }
예제 #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]);
 }