Exemplo n.º 1
0
 public void TestThatFlightHasCorrectBasePriceFor20DayFlight()
 {
     DateTime dateTestFlightLeaves = new DateTime(2011, 3, 18);
     DateTime dateTestFlightReturns = new DateTime(2011, 4, 7);
     var target = new Flight(dateTestFlightLeaves, dateTestFlightReturns, someMiles);
     Assert.AreEqual(600, target.getBasePrice());
 }
Exemplo n.º 2
0
 public void TestThatFlightHasCorrectBasePriceForTwoDays()
 {
     DateTime start = new DateTime(2005, 9, 17);
     DateTime end = new DateTime(2005, 9, 19);
     var target = new Flight(start, end, 500);
     Assert.AreEqual(240, target.getBasePrice());
 }
Exemplo n.º 3
0
        public void TestThatTwoFlightsAreEqual()
        {
            var flightOne = new Flight(StartTime, EndTime, miles);
            var flightTwo = new Flight(StartTime, EndTime, miles);

            Assert.True(flightOne.Equals(flightTwo));
        }
Exemplo n.º 4
0
 public void TestThatFlightHasIncorrectBasePriceFor1DayFlight()
 {
     DateTime dateTestFlightLeaves = new DateTime(2011, 3, 18);
     DateTime dateTestFlightReturns = new DateTime(2011, 3, 19);
     var target = new Flight(dateTestFlightLeaves, dateTestFlightReturns, someMiles);
     Assert.AreNotEqual(230, target.getBasePrice());
 }
Exemplo n.º 5
0
        public void TestThatAFlightDoesNotEqualAnotherObject()
        {
            var flight = new Flight(StartTime, EndTime, miles);
            var hotel = new Hotel(5);

            Assert.False(flight.Equals(hotel));
        }
Exemplo n.º 6
0
        public void TestThatFlightsWithDifferentStartDatesAreNotEqual()
        {
            var f1 = new Flight(new DateTime(2014, 1, 1), ValidEndDate, ValidMiles);
            var f2 = new Flight(new DateTime(2014, 1, 2), ValidEndDate, ValidMiles);

            Assert.AreNotEqual(f1, f2);
        }
Exemplo n.º 7
0
        public void TestThatFlightsWithDifferentMilesAreNotEqual()
        {
            var f1 = new Flight(ValidStartDate, ValidEndDate, 1);
            var f2 = new Flight(ValidStartDate, ValidEndDate, 2);

            Assert.AreNotEqual(f1, f2);
        }
Exemplo n.º 8
0
 public void TestThatFlightHasCorrectBasePriceForTravelOnSameDay()
 {
     DateTime dateFlightLeaves = new DateTime(2012, 1, 1);
     DateTime dateFlightReturns = new DateTime(2012, 1, 1);
     var target = new Flight(dateFlightLeaves, dateFlightReturns, mileage);
     Assert.AreEqual(200, target.getBasePrice());
 }
Exemplo n.º 9
0
 public void TesThatFlightHasCorrectBasePriceForOneDayFlight()
 {
     DateTime dateTestFlightLeaves = new DateTime(2010, 1, 18);
     DateTime dateTestFlightReturns = new DateTime(2010, 1, 19);
     var target = new Flight(dateTestFlightLeaves, dateTestFlightReturns, someMiles);
     Assert.AreEqual(220, target.getBasePrice());
 }
Exemplo n.º 10
0
 public void TestThatFlightInitializes()
 {
     DateTime startDate = new DateTime(2012, 3, 4);
     DateTime endDate = new DateTime(2012, 3, 7);
     var target = new Flight(startDate, endDate, 5);
     Assert.IsNotNull(target);
 }
Exemplo n.º 11
0
 public void TestThatFlightBookingPriceCorrectZeroDayDifference()
 {
     DateTime startDate = new DateTime(2012, 3, 4);
     DateTime endDate = new DateTime(2012, 3, 4);
     var target = new Flight(startDate, endDate, 5);
     Assert.AreEqual(200, target.getBasePrice());
 }
Exemplo n.º 12
0
        public void TestFlightNotEqualToOtherObject()
        {
            var f1 = new Flight(ValidStartDate, ValidEndDate, ValidMiles);
            var o2 = new Object();

            Assert.AreNotEqual(f1, o2);
        }
Exemplo n.º 13
0
        public void TestEqualsMethodWithTwoDifferentFlights()
        {
            Flight flight1 = new Flight(startDate, endDate, 500);
            Flight flight2 = new Flight(startDate, endDate, 100);

            Assert.False(flight1.Equals(flight2));
        }
Exemplo n.º 14
0
        public void TestEqualsMethodWithTwoEquivalentFlights()
        {
            Flight flight1 = new Flight(startDate, endDate, someMiles);
            Flight flight2 = new Flight(startDate, endDate, someMiles);

            Assert.True(flight1.Equals(flight2));
        }
Exemplo n.º 15
0
        public void TestSameFlightsAreEqual()
        {
            var f1 = new Flight(ValidStartDate, ValidEndDate, ValidMiles);
            var f2 = new Flight(ValidStartDate, ValidEndDate, ValidMiles);

            Assert.AreEqual(f1, f2);
        }
Exemplo n.º 16
0
 public void TestFlightsInequalityDueToStartDate()
 {
     DateTime rDate = DateTime.Now.AddDays(10);
     var target1 = new Flight(DateTime.Now, rDate, 10);
     var target2 = new Flight(DateTime.Now, rDate, 10);
     Assert.IsFalse(target1.Equals(target2));
 }
Exemplo n.º 17
0
 public void TestFlightsInequalityDueToEndDate()
 {
     DateTime sDate = DateTime.Now;
     var target1 = new Flight(sDate, DateTime.Now.AddDays(10), 10);
     var target2 = new Flight(sDate, DateTime.Now.AddDays(10), 10);
     Assert.IsFalse(target1.Equals(target2));
 }
Exemplo n.º 18
0
 public void TestThatFlightInitializes()
 {
     DateTime StartDate = new DateTime(2009, 11, 1);
     DateTime EndDate = new DateTime(2009, 11, 1);
     var target = new Flight(StartDate, EndDate, 700);
     Assert.IsNotNull(target);
 }
Exemplo n.º 19
0
 private bool Equals(Flight obj)
 {
     bool l = obj.dateThatFlightLeaves.Equals(this.dateThatFlightLeaves);
     bool r = obj.dateThatFlightReturns.Equals(this.dateThatFlightReturns);
     bool m = obj.Miles.Equals(this.Miles);
     return l && r && m;
 }
Exemplo n.º 20
0
 public void TestThatFlightThrowsOnBadDistance()
 {
     var start = new DateTime(1999, 1, 1);
     var end = new DateTime(1999, 1, 2);
     int miles = -5;
     var target = new Flight(start, end, miles);
 }
Exemplo n.º 21
0
 public void TestThatFlightStoresMiles()
 {
     DateTime startDate = new DateTime(2012, 3, 4);
     DateTime endDate = new DateTime(2012, 3, 7);
     var target = new Flight(startDate, endDate, 5);
     Assert.AreEqual(5, target.Miles);
 }
Exemplo n.º 22
0
 public void TestFlightsInequalityDueToMiles()
 {
     DateTime sDate = DateTime.Now;
     DateTime rDate = DateTime.Now.AddDays(10);
     Flight target1 = new Flight(sDate, rDate, 10);
     Flight target2 = new Flight(sDate, rDate, 20);
     Assert.IsFalse(target1.Equals(target2));
 }
Exemplo n.º 23
0
 public void TestFlightsEquality()
 {
     DateTime sDate = DateTime.Now;
     DateTime rDate = DateTime.Now.AddDays(10);
     Flight target1 = new Flight(sDate, rDate, 10);
     Flight target2 = new Flight(sDate, rDate, 10);
     Assert.IsTrue(target1.Equals(target2));
 }
Exemplo n.º 24
0
 public void TestThatFlightHasCorrectBasePriceForTwoDayTrip()
 {
     var start = new DateTime(1999, 1, 1);
     var end = new DateTime(1999, 1, 3);
     int miles = 100;
     var target = new Flight(start, end, miles);
     Assert.AreEqual(240, target.getBasePrice());
 }
Exemplo n.º 25
0
 public void TestThatFlightEqualsWorks()
 {
     var target = new Flight(System.DateTime.Today, System.DateTime.Parse("10/5/2012"), 100);
     var target2 = new Flight(System.DateTime.Today, System.DateTime.Parse("10/5/2012"), 100);
     var target3 = new Flight(System.DateTime.Today, System.DateTime.Parse("10/6/2012"), 100);
     Assert.True(target.Equals(target2));
     Assert.False(target.Equals(target3));
 }
Exemplo n.º 26
0
 public void TestFlightEqualsTrue()
 {
     DateTime StartDate = new DateTime(2009, 11, 1);
     DateTime EndDate = new DateTime(2009, 11, 1);
     var target = new Flight(StartDate, EndDate, 700);
     var target2 = new Flight(StartDate, EndDate, 700);
     Assert.True(target.Equals(target2));
 }
Exemplo n.º 27
0
        public void TestEquals()
        {
            var target1 = new Flight(startDate, endDate, someMiles);
            var target2 = new Flight(startDate, endDate, someMiles);
            var target3 = new Flight(startDate, new DateTime(2011, 3, 26), someMiles);

            Assert.AreEqual(target1, target2);
            Assert.AreNotEqual(target1, target3);
        }
Exemplo n.º 28
0
        public void TestThatFlightlInitializes()
        {
            var start = new DateTime(1999, 1, 1);
            var end = new DateTime(1999, 2, 1);
            int miles = 100;

            var target = new Flight(start, end, miles);
            Assert.IsNotNull(target);
        }
Exemplo n.º 29
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);
        }
Exemplo n.º 30
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]);
 }