public void build_is_idepotent()
        {
            var voyageNumber = new VoyageNumber("12");
            var departureLocation = new BookingApi.Domain.Location.Location(new UnLocode("AZ23H"), "HAMBOURG");
            var arrivalLocation = new BookingApi.Domain.Location.Location(new UnLocode("XE44K"), "TUNIS");
            var departureDataTime = new DateTime(2010, 4, 10);
            var arrivalDataTime = new DateTime(2010, 5, 15);

            var voyageBuilder = new VoyageBuilder(voyageNumber, departureLocation).AddMovement(arrivalLocation, departureDataTime, arrivalDataTime);

            var voyage1 = voyageBuilder.Build();
            var voyage2 = voyageBuilder.Build();

            Assert.True(voyage1.Number == voyage2.Number);
            Assert.True(voyage1.Schedule == voyage2.Schedule);
        }
Exemplo n.º 2
0
        public void should_create_instance_with_correct_ctor_parameters()
        {
            // AUTOFIXTURE
            //var fixture = new Fixture();

            //fixture.Register(UnLocodeHelpers.GetNewUnLocode);

            //fixture.Register<IList<CarrierMovement>>(() => fixture.CreateMany<CarrierMovement>(50).ToList());

            ////fixture.Register(() => fixture.CreateMany<CarrierMovement>());

            //var schedule = fixture.CreateAnonymous<Schedule>();

            //Assert.NotNull(schedule);

            var carrierMovements = new List<CarrierMovement>();

            var deparureUnLocode1 = new UnLocode("AB44D");
            var departureLocation1 = new BookingApi.Domain.Location.Location(deparureUnLocode1, "HAMBOURG");
            var arrivalUnLocode1 = new UnLocode("XX44D");
            var arrivalLocation1 = new BookingApi.Domain.Location.Location(arrivalUnLocode1, "TUNIS");
            var departureDate1 = new DateTime(2010, 3, 15);
            var arrivalDate1 = new DateTime(2010, 5, 12);

            var carrierMovement1 = new CarrierMovement(departureLocation1, arrivalLocation1, departureDate1, arrivalDate1);

            var deparureUnLocode2 = new UnLocode("CXRET");
            var departureLocation2 = new BookingApi.Domain.Location.Location(deparureUnLocode2, "GDANSK");
            var arrivalUnLocode2 = new UnLocode("ZEZD4");
            var arrivalLocation2 = new BookingApi.Domain.Location.Location(arrivalUnLocode2, "LE HAVRE");
            var departureDate2 = new DateTime(2010, 3, 18);
            var arrivalDate2 = new DateTime(2010, 3, 31);

            var carrierMovement2 = new CarrierMovement(departureLocation2, arrivalLocation2, departureDate2, arrivalDate2);

            carrierMovements.Add(carrierMovement1);
            carrierMovements.Add(carrierMovement2);

            Assert.NotNull(new Schedule(carrierMovements));
        }
Exemplo n.º 3
0
        public void should_throw_exception_with_collection_containing_null_values()
        {
            Assert.Throws<ArgumentException>(
                    delegate
                    {
                        var carrierMovements = new List<CarrierMovement>();
                        var deparureUnLocode = new UnLocode("AB44D");
                        var departureLocation = new BookingApi.Domain.Location.Location(deparureUnLocode, "HAMBOURG");
                        var arrivalUnLocode = new UnLocode("XX44D");
                        var arrivalLocation = new BookingApi.Domain.Location.Location(arrivalUnLocode, "TUNIS");
                        var departureDate = new DateTime(2010, 3, 15);
                        var arrivalDate = new DateTime(2010, 5, 12);
                        var carrierMovement1 = new CarrierMovement(departureLocation, arrivalLocation, departureDate,
                                                                                  arrivalDate);
                        CarrierMovement carrierMovement2 = null;
                        carrierMovements.Add(carrierMovement1);
                        carrierMovements.Add(carrierMovement2);

                        new Schedule(carrierMovements);
                    }
                );
        }
Exemplo n.º 4
0
 public void should_never_equal_to_null()
 {
     var location = new BookingApi.Domain.Location.Location(new UnLocode("ABCDE"), "Varsovie");
     Assert.False(location.Equals(null));
 }
Exemplo n.º 5
0
 public void should_always_equal_to_itself()
 {
     var location = new BookingApi.Domain.Location.Location(new UnLocode("ABCDE"), "Varsovie");
     Assert.True(location.Equals(location));
 }
Exemplo n.º 6
0
        private static bool EqulaOperator(Location left, Location right)
        {
            if (ReferenceEquals(left, null) ^ ReferenceEquals(right, null))
            {
                return false;
            }

            return ReferenceEquals(left, null) || left.Equals(right);
        }
        public void build_returns_valid_voyage_instance_with_valid_inputs()
        {
            // AUTOFIXTURE
            //var fixture = new Fixture();

            //var departureLocation = fixture.CreateAnonymous<Location>();
            //var arrivalLocation = fixture.CreateAnonymous<Location>();
            //var departureTime = fixture.CreateAnonymous<DateTime>();
            //var arrivalTime = fixture.CreateAnonymous<DateTime>().AddDays(11);

            //fixture.Register(UnLocodeHelpers.GetNewUnLocode);
            //var voyageNumber = fixture.CreateAnonymous<VoyageNumber>();
            //fixture.Register(() => new VoyageBuilder(voyageNumber, departureLocation));
            //var voyageBuilder = fixture.CreateAnonymous<VoyageBuilder>();

            //fixture.Register(() => new CarrierMovement(departureLocation, arrivalLocation, departureTime, arrivalTime));
            //var carrierMovements = fixture.CreateMany<CarrierMovement>(1).ToList();
            //fixture.Register(() => new Schedule(carrierMovements));
            //var schedule = fixture.CreateAnonymous<Schedule>();

            //var voyage = voyageBuilder.AddMovement(arrivalLocation, departureTime, arrivalTime).Build();

            //Assert.True(voyage.Number.Equals(voyageNumber));
            //Assert.True(voyage.Schedule.Equals(schedule));

            var voyageNumber = new VoyageNumber("12");
            var departureLocation = new BookingApi.Domain.Location.Location(new UnLocode("AZ23H"), "HAMBOURG");
            var arrivalLocation = new BookingApi.Domain.Location.Location(new UnLocode("XE44K"), "TUNIS");
            var departureDataTime = new DateTime(2010, 4, 10);
            var arrivalDataTime = new DateTime(2010, 5, 15);
            var schedule =
                new Schedule(new List<CarrierMovement>
                                 {
                                     new CarrierMovement(departureLocation, arrivalLocation, departureDataTime,
                                                         arrivalDataTime)
                                 });

            BookingApi.Domain.Voyage.Voyage voyage = new VoyageBuilder(voyageNumber, departureLocation)
                .AddMovement(arrivalLocation, departureDataTime, arrivalDataTime).Build();

            Assert.True(voyage.Number.Equals(voyageNumber));
            Assert.True(voyage.Schedule.Equals(schedule));
        }
        public void build_throws_exception_if_called_without_valid_addMovement()
        {
            Assert.Throws<ArgumentException>(
                   delegate
                   {
                       var voyageNumber = new VoyageNumber("12");
                       var departureLocation = new BookingApi.Domain.Location.Location(new UnLocode("AZ23H"), "HAMBOURG");
                       var arrivalLocation = new BookingApi.Domain.Location.Location(new UnLocode("XE44K"), "TUNIS");
                       var departureDataTime = new DateTime(2010, 4, 10);
                       var arrivalDataTime = new DateTime(2010, 5, 15);
                       var schedule =
                           new Schedule(new List<CarrierMovement>
                                 {
                                     new CarrierMovement(departureLocation, arrivalLocation, departureDataTime,
                                                         arrivalDataTime)
                                 });

                       BookingApi.Domain.Voyage.Voyage voyage = new VoyageBuilder(voyageNumber, departureLocation).Build();

                       voyage.Number.Equals(voyageNumber);
                       voyage.Schedule.Equals(schedule);
                   }
               );
        }