public async Task Test_SerializationAsync()
        {
            // Get the client.
            IGeocodingClient client = Fixture.GetRequiredService <IGeocodingClient>();

            // Set up the request.
            var request = new GeocodeRequest(
                "1600 Pennsylvania Avenue, Washington D.C., United States"
                );

            // Make the request.
            var results = await client
                          .GeocodeAsync(request, default)
                          .ConfigureAwait(false);

            // Create the container.
            var expected = new Container <GeocodeResponse> {
                Value = results
            };

            // Serialize to a string.
            string json = JsonSerializer.Serialize(expected);

            // Serialize again.
            var actual = JsonSerializer.Deserialize <Container <GeocodeResponse> >(json);

            // Compare.
            Assert.Equal(expected.Value.Status, actual.Value.Status);
            Assert.Equal(expected.Value.Results.Count, actual.Value.Results.Count);
        }
 public void Initialize()
 {
     _mockMessage  = "Random error message 6EE73B6E-45FA-4394-9B42-076669470C52";
     _mockLocation = new Location
     {
         lng = "-123.456",
         lat = "33.33333"
     };
     _restClientMock = new Mock <IRestClient>();
     _client         = new GeocodingClient(_restClientMock.Object);
 }
        public async Task Test_GeocodeAsync()
        {
            // Get the client.
            IGeocodingClient client = Fixture.GetRequiredService <IGeocodingClient>();

            // Set up the request.
            var request = new GeocodeRequest(
                "1600 Pennsylvania Avenue, Washington D.C., United States"
                );

            // Make the request.
            var actual = await client
                         .GeocodeAsync(request, default)
                         .ConfigureAwait(false);

            // Validate response.
            Assert.Equal("OK", actual.Status);
            Assert.Single(actual.Results);
            Assert.Contains(actual.Results.Single().AddressComponents, c => c.LongName == "1600");
        }
Exemple #4
0
 public GeocodingFunctionality(IGeocodingClient client)
 {
     _client = client;
 }