Esempio n. 1
0
        public void Ctor_01()
        {
            // arrange:
            UnLocode   final     = new UnLocode("FINAL");
            TrackingId id        = new TrackingId("CLAIM");
            IItinerary itinerary = MockRepository.GenerateStrictMock <IItinerary>();

            itinerary.Expect(i => i.FinalArrivalDate).Return(DateTime.UtcNow).Repeat.AtLeastOnce();
            itinerary.Expect(i => i.FinalArrivalLocation).Return(final).Repeat.AtLeastOnce();
            IRouteSpecification specification = MockRepository.GenerateStrictMock <IRouteSpecification>();

            specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
            CargoState previousState = MockRepository.GenerateStrictMock <CargoState>(id, specification);

            previousState = MockRepository.GenerateStrictMock <CargoState>(previousState, itinerary);
            previousState.Expect(s => s.IsUnloadedAtDestination).Return(true).Repeat.AtLeastOnce();
            previousState.Expect(s => s.TransportStatus).Return(TransportStatus.InPort).Repeat.AtLeastOnce();
            DateTime claimDate = DateTime.UtcNow;


            // act:
            ClaimedCargo state = new ClaimedCargo(previousState, claimDate);

            // assert:
            Assert.AreEqual(TransportStatus.Claimed, state.TransportStatus);
            Assert.AreEqual(RoutingStatus.Routed, state.RoutingStatus);
            Assert.AreSame(final, state.LastKnownLocation);
            Assert.AreSame(specification, state.RouteSpecification);
            Assert.IsNull(state.CurrentVoyage);
            Assert.IsTrue(state.IsUnloadedAtDestination);
            itinerary.VerifyAllExpectations();
            specification.VerifyAllExpectations();
            previousState.VerifyAllExpectations();
        }
Esempio n. 2
0
        public void Ctor_05()
        {
            // arrange:
            TrackingId id        = new TrackingId("CLAIM");
            IItinerary itinerary = MockRepository.GenerateStrictMock <IItinerary>();

            itinerary.Expect(i => i.FinalArrivalDate).Return(DateTime.UtcNow).Repeat.AtLeastOnce();
            IRouteSpecification specification = MockRepository.GenerateStrictMock <IRouteSpecification>();

            specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
            CargoState previousState = MockRepository.GenerateStrictMock <CargoState>(id, specification);

            previousState = MockRepository.GenerateStrictMock <CargoState>(previousState, itinerary);
            previousState.Expect(s => s.IsUnloadedAtDestination).Return(false).Repeat.AtLeastOnce();
            previousState.Expect(s => s.TransportStatus).Return(TransportStatus.InPort).Repeat.AtLeastOnce();
            DateTime claimDate = DateTime.UtcNow;


            // act:
            Assert.Throws <ArgumentException>(delegate { new ClaimedCargo(previousState, claimDate); });

            // assert:
            itinerary.VerifyAllExpectations();
            specification.VerifyAllExpectations();
            previousState.VerifyAllExpectations();
        }