public async Task <double> Get(string origin, string destination) { var originCode = new IataAirportCode(origin); var destinationCode = new IataAirportCode(destination); return(await _distanceCalculator.DistanceBetween(originCode, destinationCode)); }
public Command(IataAirportCode fromAirport, IataAirportCode toAirport, LocalTime departureTime, LocalTime arrivalTime) { FromAirport = fromAirport ?? throw new ArgumentNullException(nameof(fromAirport)); ToAirport = toAirport ?? throw new ArgumentNullException(nameof(toAirport)); DepartureTime = departureTime; ArrivalTime = arrivalTime; }
public FlightCreated(FlightId flightId, IataAirportCode fromAirport, IataAirportCode toAirport, LocalTime departureTime, LocalTime arrivalTime) { FlightId = flightId; FromAirport = fromAirport ?? throw new ArgumentNullException(nameof(fromAirport)); ToAirport = toAirport ?? throw new ArgumentNullException(nameof(toAirport)); DepartureTime = departureTime; ArrivalTime = arrivalTime; }
public void Should_AllowToCreateInstance_For3LetterString() { // Arrange const string code = "TST"; // Act var instance = new IataAirportCode(code); // Assert Assert.AreEqual(code, instance.Value, "Should save given code as value"); }
public async Task Should_CalculateDistance() { // Arrange var orig = new IataAirportCode("ORG"); var dest = new IataAirportCode("DST"); var origCoordinate = new Coordinate(0, 0); var destCoordinate = new Coordinate(0, 1); _locationProviderMock.Setup(_ => _.LocationOf(orig)).Returns(Task.FromResult(origCoordinate)); _locationProviderMock.Setup(_ => _.LocationOf(dest)).Returns(Task.FromResult(destCoordinate)); // Act var result = await _calculator.DistanceBetween(orig, dest); // Assert Assert.AreEqual(111.2d, result); }
public override int GetHashCode() { int hash = 1; if (IataAirportCode.Length != 0) { hash ^= IataAirportCode.GetHashCode(); } if (IcaoAirportCode.Length != 0) { hash ^= IcaoAirportCode.GetHashCode(); } if (CityName.Length != 0) { hash ^= CityName.GetHashCode(); } if (localizedCityName_ != null) { hash ^= LocalizedCityName.GetHashCode(); } if (AirportName.Length != 0) { hash ^= AirportName.GetHashCode(); } if (localizedAirportName_ != null) { hash ^= LocalizedAirportName.GetHashCode(); } if (CountryCode.Length != 0) { hash ^= CountryCode.GetHashCode(); } if (Timezone.Length != 0) { hash ^= Timezone.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public async Task <Coordinate> LocationOf(IataAirportCode airportCode) { var airportInfo = await _airportsService.GetAirportInfo(airportCode.Value); return(new Coordinate(airportInfo.Location.Lat, airportInfo.Location.Lon)); }