Ejemplo n.º 1
0
        public async Task <Kilometer> GetDistanceBetweenLocations(Location a, Location b)
        {
            var request  = _getDistanceRequestMapper.Map(a, b);
            var response = await _httpClient.PostAsync(distanceEndpointAddress, request);

            return(_getDistanceResponseMapper.Map(response));
        }
        public async Task WhenLocations_ShouldInvokeAaaEndpoint()
        {
            // Arrange
            var expectedEndpoint = "http://api.aaa.com/api/distance";
            var expectedRequest  = new StringContent(_fixture.Create <string>());

            _getDistanceRequestMapper
            .Map(Arg.Any <Location>(), Arg.Any <Location>())
            .Returns(expectedRequest);

            // Act
            await _sut.GetDistanceBetweenLocations(_from, _to);

            // Assert
            await _httpClient
            .Received(1)
            .PostAsync(Arg.Is(expectedEndpoint), Arg.Is(expectedRequest));
        }