Beispiel #1
0
        public void EndTripShouldUpdateCabLocationAndReturnCabToPool()
        {
            var dropLocation = new GeoCoordinate(13, 77);
            var trip         = new Domain.Trip("1", "1234", "100", new GeoCoordinate(12, 77), null,
                                               DateTime.Now.AddHours(-1), DateTime.MinValue, TripStatus.InProgress);
            var tripRepo = new Mock <ITripRepository>();

            tripRepo.Setup(t => t.Get("1")).Returns(trip);
            var cabLocationService   = new Mock <ICabLocationService>();
            var availableCabsService = new Mock <IAvailableCabsService>();
            var bookingService       = new Mock <IBookingService>();

            var tripService = new TripService(tripRepo.Object, availableCabsService.Object, bookingService.Object, cabLocationService.Object);

            tripService.EndTrip("1", dropLocation, DateTime.Now);

            tripRepo.Verify(t => t.Save(It.Is <Domain.Trip>(updatedTrip => updatedTrip.Id.Equals(trip.Id))));
            availableCabsService.Verify(a => a.ReturnCabToPool("100"));
            cabLocationService.Verify(c => c.SetCabLocation("100", dropLocation));
        }