public void two_instances_wtih_the_same_number_should_be_equal() { var instance1 = new VoyageNumber("ABC"); var instance2 = new VoyageNumber("ABC"); Assert.True((instance1 == instance2)); Assert.False((instance1 != instance2)); }
public void two_instances_wtih_different_numbers_should_not_be_equal() { var instance1 = new VoyageNumber("ABC"); var instance2 = new VoyageNumber("ABD"); Assert.False((instance1 == instance2)); Assert.True((instance1 != instance2)); }
public static Voyage Empty = new Voyage(new VoyageNumber(""), Schedule.Empty); // Null object pattern #endregion Fields #region Constructors /// <summary> /// Creates new Voyage object. /// </summary> /// <param name="number">Identifier of this voyage.</param> /// <param name="schedule">Voyage schedule.</param> public Voyage(VoyageNumber number, Schedule schedule) { if (number == null) throw new ArgumentNullException("number"); if (schedule == null) throw new ArgumentNullException("schedule"); Number = number; Schedule = schedule; }
/// <summary> /// Creates a new instance of <see cref="VoyageBuilder"/>. /// </summary> /// <param name="voyageNumber">Voyage number.</param> /// <param name="departureLocation">Departure location.</param> public VoyageBuilder(VoyageNumber voyageNumber, Location.Location departureLocation) { if (voyageNumber == null) { throw new ArgumentNullException("voyageNumber"); } if (departureLocation == null) { throw new ArgumentNullException("departureLocation"); } _voyageNumber = voyageNumber; _departureLocation = departureLocation; }
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); }
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); } ); }