Example #1
0
        public void Equals_withDifferentItineraries_isFalse()
        {
            // arrange:
            DateTime   arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
            TrackingId identifier  = new TrackingId("CARGO01");
            IItinerary itinerary   = MockRepository.GenerateStrictMock <IItinerary>();

            itinerary.Expect(i => i.Equals(null)).Return(false).Repeat.Any();
            itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
            IRouteSpecification route = MockRepository.GenerateStrictMock <IRouteSpecification>();

            route.Expect(s => s.Equals(route)).Return(true).Repeat.Any();
            route.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
            FakeState state1 = new FakeState(identifier, route);

            state1 = new FakeState(state1, itinerary);
            state1._lastKnownLocation = new Challenge00.DDDSample.Location.UnLocode("TESTA");
            FakeState state2 = new FakeState2(identifier, route);

            state2._lastKnownLocation = new Challenge00.DDDSample.Location.UnLocode("TESTA");

            // act:

            // assert:
            Assert.IsFalse(state1.Equals(state2));
        }
Example #2
0
        public void Equals_onDifferentVoyage_isFalse_02()
        {
            // arrange:
            DateTime   arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
            TrackingId identifier  = new TrackingId("CARGO01");
            IItinerary itinerary   = MockRepository.GenerateStrictMock <IItinerary>();

            itinerary.Expect(i => i.Equals(null)).Return(false).Repeat.Any();
            itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
            itinerary.Expect(i => i.Equals(itinerary)).Return(true).Repeat.Any();
            IRouteSpecification route = MockRepository.GenerateStrictMock <IRouteSpecification>();

            route.Expect(s => s.Equals(route)).Return(true).Repeat.Any();
            route.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
            FakeState state1 = new FakeState(identifier, route);

            state1 = new FakeState(state1, itinerary);
            state1._currentVoyage = null;
            FakeState state2 = new FakeState2(identifier, route);

            state2 = new FakeState(state2, itinerary);

            // act:

            // assert:
            Assert.IsFalse(state1.Equals(state2));
        }
Example #3
0
        public void Equals_withNull_isFalse()
        {
            // arrange:
            TrackingId          identifier = new TrackingId("CARGO01");
            IRouteSpecification route      = MockRepository.GenerateStrictMock <IRouteSpecification>();
            FakeState           state      = new FakeState(identifier, route);

            Assert.IsFalse(state.Equals((CargoState)null));
            Assert.IsFalse(state.Equals((IDelivery)null));
        }
Example #4
0
        public void ToString_containsStateName()
        {
            // arrange:
            TrackingId          identifier = new TrackingId("CARGO01");
            IRouteSpecification route      = MockRepository.GenerateStrictMock <IRouteSpecification>();
            CargoState          state      = new FakeState(identifier, route);

            // act:
            string stateString = state.ToString();

            // assert:
            Assert.IsTrue(stateString.Contains(state.GetType().Name));
        }
Example #5
0
        public void Ctor_withSameArgs_produceDifferentCalculationDate()
        {
            // arrange:
            TrackingId          identifier = new TrackingId("CARGO01");
            IRouteSpecification route      = MockRepository.GenerateStrictMock <IRouteSpecification>();

            // act:
            CargoState state1 = new FakeState(identifier, route);

            Thread.Sleep(100);
            CargoState state2 = new FakeState(identifier, route);

            // assert:
            Assert.AreNotEqual(state1.CalculationDate, state2.CalculationDate);
        }
Example #6
0
        public void Equals_withDifferentIdentifiers_isFalse()
        {
            // arrange:
            TrackingId          identifier = new TrackingId("CARGO01");
            IRouteSpecification route      = MockRepository.GenerateStrictMock <IRouteSpecification>();
            FakeState           state1     = new FakeState(identifier, route);

            state1._lastKnownLocation = new Challenge00.DDDSample.Location.UnLocode("TESTA");
            FakeState state2 = new FakeState(new TrackingId("CARGO02"), route);

            state2._lastKnownLocation = new Challenge00.DDDSample.Location.UnLocode("TESTA");

            // act:

            // assert:
            Assert.IsFalse(state1.Equals(state2));
        }
Example #7
0
        public void Ctor_withValidArgs_works()
        {
            // arrange:
            DateTime            runTime    = DateTime.UtcNow;
            TrackingId          identifier = new TrackingId("CARGO01");
            IRouteSpecification route      = MockRepository.GenerateStrictMock <IRouteSpecification>();

            // act:
            CargoState state = new FakeState(identifier, route);

            // assert:
            Assert.LessOrEqual(runTime, state.CalculationDate);
            Assert.AreSame(identifier, state.Identifier);
            Assert.AreSame(route, state.RouteSpecification);
            Assert.AreEqual(RoutingStatus.NotRouted, state.RoutingStatus);
            Assert.IsFalse(state.EstimatedTimeOfArrival.HasValue);
        }
Example #8
0
		public void Equals_withEverythingRelevantEquals_isTrue()
		{
			// arrange:
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			TrackingId identifier = new TrackingId("CARGO01");
			IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary.Expect(i => i.Equals(null)).Return(false).Repeat.Any();
			itinerary.Expect(i => i.Equals(itinerary)).Return(true).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(s => s.Equals(route)).Return(true).Repeat.Any();
			route.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
			FakeState state1 = new FakeState(identifier, route);
			FakeState state2 = new FakeState(state1, itinerary);
			state1 = new FakeState(state1, itinerary);
		
			// act:
		
			// assert:
			Assert.IsTrue(state1.Equals(state2));
		}
Example #9
0
		public void Equals_onDifferentVoyage_isFalse()
		{
			// arrange:
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			TrackingId identifier = new TrackingId("CARGO01");
			IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary.Expect(i => i.Equals(null)).Return(false).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			itinerary.Expect(i => i.Equals(itinerary)).Return(true).Repeat.Any();
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(s => s.Equals(route)).Return(true).Repeat.Any();
			route.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
			FakeState state1 = new FakeState(identifier, route);
			state1 = new FakeState(state1, itinerary);
			FakeState state2 = new FakeState2(identifier, route);
			state2 = new FakeState(state2, itinerary);
			state2._currentVoyage = new Challenge00.DDDSample.Voyage.VoyageNumber("DIFFERENT");
		
			// act:
		
			// assert:
			Assert.IsFalse(state1.Equals(state2));
		}
Example #10
0
		public void Equals_withDifferentIdentifiers_isFalse()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			FakeState state1 = new FakeState(identifier, route);
			state1._lastKnownLocation = new Challenge00.DDDSample.Location.UnLocode("TESTA");
			FakeState state2 = new FakeState(new TrackingId("CARGO02"), route);
			state2._lastKnownLocation = new Challenge00.DDDSample.Location.UnLocode("TESTA");
		
			// act:
		
			// assert:
			Assert.IsFalse(state1.Equals(state2));
		}
Example #11
0
		public void Equals_withNull_isFalse()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			FakeState state = new FakeState(identifier, route);
			
			Assert.IsFalse(state.Equals((CargoState)null));
			Assert.IsFalse(state.Equals((IDelivery)null));
		}
Example #12
0
		public void ToString_containsStateName()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			CargoState state = new FakeState(identifier, route);
		
			// act:
			string stateString = state.ToString();
		
			// assert:
			Assert.IsTrue(stateString.Contains(state.GetType().Name));
		}
Example #13
0
		public void Ctor_withSameArgs_produceDifferentCalculationDate()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			
			// act:
			CargoState state1 = new FakeState(identifier, route);
			Thread.Sleep(100);
			CargoState state2 = new FakeState(identifier, route);
		
			// assert:
			Assert.AreNotEqual(state1.CalculationDate, state2.CalculationDate);
		}
Example #14
0
		public void Ctor_withValidArgs_works()
		{
			// arrange:
			DateTime runTime = DateTime.UtcNow;
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			
			// act:
			CargoState state = new FakeState(identifier, route);
		
			// assert:
			Assert.LessOrEqual(runTime, state.CalculationDate);
			Assert.AreSame(identifier, state.Identifier);
			Assert.AreSame(route, state.RouteSpecification);
			Assert.AreEqual(RoutingStatus.NotRouted, state.RoutingStatus);
			Assert.IsFalse(state.EstimatedTimeOfArrival.HasValue);
		}