public async Task AddRideAsync_WhenRideIsASoloRide_ReturnsACreateRideResponseContainingTheCorrectPrice() { decimal distance = 10; decimal calculatedPrice = 100; _googleMapsApiService.GetDistanceInKmAsync(Arg.Any <string>(), Arg.Any <string>()) .ReturnsForAnyArgs(distance); _soloRidePriceStrategy.CalculatePrice(distance).Returns(calculatedPrice); //Stub the solo strategy var expectedResponse = new CreateRideResponse { Price = calculatedPrice }; _mapper.Map <CreateRideResponse>(null).ReturnsForAnyArgs(expectedResponse); _mapper.Map <SoloRide>(null) .ReturnsForAnyArgs(new SoloRide { StartDestination = _anAddress, EndDestination = _anAddress }); var request = new CreateRideRequest { StartDestination = _anAddress, EndDestination = _anAddress, RideType = RideType.SoloRide }; var response = await _rideService.AddRideAsync(request, "aCustomerId"); Assert.That(response.Price, Is.EqualTo(calculatedPrice)); }
public async Task AddRideAsync() { // Arrange // Act await _rideService.AddRideAsync(_testRide1); // Assert var testRideInDb = await _context.Rides.FirstAsync(r => r.Id == _testRide1.Id); Assert.AreEqual(3, testRideInDb.AvailableSeats); Assert.AreEqual((byte)WeekDay.WeekDays, testRideInDb.Repeating); Assert.AreEqual(_testOwner.Name, testRideInDb.Creator.Name); Assert.AreEqual(true, testRideInDb.IsSeekingRiders); }