Ejemplo n.º 1
0
        public void ShouldReportInvariantViolationWhenGivenAJourneyWithLiftANewLiftIsAddedWithSamePerson()
        {
            var journey = new Journey(JourneyId, new DateTime(), new Distance(20m, DistanceUnit.Kilometer), _eventBus.Publish)
                          .AddLift(PersonId, new Distance(10m, DistanceUnit.Kilometer));

            journey.AddLift(PersonId, new Distance(10m, DistanceUnit.Kilometer));
        }
Ejemplo n.º 2
0
        public void Execute(AddJourneyWithLiftsCommand command)
        {
            var routeDistance = new Distance(command.RouteDistance, DistanceUnit.Kilometer);
            var journey       = new Journey(command.JourneyId, command.DateOfOccurrence, routeDistance, _eventPublisher);

            foreach (var lift in command.Lifts)
            {
                var liftDistance = new Distance(lift.LiftDistance, DistanceUnit.Kilometer);
                var personId     = GetOrAddPersonWithName(lift.PersonName);
                journey = journey.AddLift(personId, liftDistance);
            }
            _repositories.Store(journey);
        }
Ejemplo n.º 3
0
        public void ShouldPublishEventWhenAddingLift()
        {
            var journey      = new Journey(JourneyId, new DateTime(), new Distance(10m, DistanceUnit.Kilometer), _eventBus.Publish);
            var liftDistance = new Distance(5m, DistanceUnit.Kilometer);

            var eventMatcher = _eventBus.Listen(() =>
            {
                journey.AddLift(PersonId, liftDistance);
            });

            eventMatcher.AssertReceivedOneEvent <LiftAddedEvent>(
                evt => evt.LiftDistance == liftDistance &&
                evt.PersonId.Equals(PersonId));
        }
Ejemplo n.º 4
0
        public void ShouldReportInvariantViolationWhenAddingLiftWithDistanceLargerThanRouteDistance()
        {
            var journey = new Journey(JourneyId, new DateTime(), new Distance(20m, DistanceUnit.Kilometer), _eventBus.Publish);

            journey.AddLift(PersonId, new Distance(40m, DistanceUnit.Kilometer));
        }