コード例 #1
0
        public void ToMiles_SetMeters_ReturnCorrectResult(double meters, double expectedResult)
        {
            // arrange
            // act
            var result = _service.ToMiles(meters);

            // assert
            Assert.True(Equals(result, expectedResult));
        }
コード例 #2
0
            public async Task <Result <double> > Handle(GetDistanceBetweenAirportsQuery request,
                                                        CancellationToken cancellationToken)
            {
                var fromTask = Task.Run(() => _airportService.GetAirport(request.From), cancellationToken);
                var toTask   = Task.Run(() => _airportService.GetAirport(request.To), cancellationToken);
                await Task.WhenAll(fromTask, toTask);

                var fromAirport = fromTask.Result;
                var toAirport   = toTask.Result;

                if (fromAirport?.Location == null || toAirport?.Location == null)
                {
                    return(Result.Failure <double>("Couldn't get an additional information about airports."));
                }

                var metersDistance = _distanceService.GetDistanceInMeters(fromAirport.Location, toAirport.Location);
                var miles          = _distanceService.ToMiles(metersDistance);

                return(Result.Success(miles));
            }