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

            // Create the request.
            var request = new TimeZoneRequest(
                // The White House
                38.8977M,
                -77.0365M,
                // 🎆🎆 July 4th, 2020 🎆🎆
                new DateTime(2020, 07, 04)
                );

            // Execute.
            TimeZoneResponse results = await client
                                       .GetTimeZoneAsync(request, default)
                                       .ConfigureAwait(false);

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

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

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

            // Compare.
            Assert.Equal(expected.Value.Status, actual.Value.Status);
            Assert.Equal(expected.Value.TimeZoneId, actual.Value.TimeZoneId);
            Assert.Equal(expected.Value.RawOffset, actual.Value.RawOffset);
        }
        public async Task Test_GetTimeZoneAsync()
        {
            // Get the client.
            ITimeZoneClient client = Fixture.GetRequiredService <ITimeZoneClient>();

            // Create the request.
            var request = new TimeZoneRequest(
                // The White House
                38.8977M,
                -77.0365M,
                // 🎆🎆 July 4th, 2020 🎆🎆
                new DateTime(2020, 07, 04)
                );

            // Execute.
            TimeZoneResponse actual = await client
                                      .GetTimeZoneAsync(request, default)
                                      .ConfigureAwait(false);

            // Assert.
            Assert.Equal(Status.OK, actual.Status);
            Assert.Equal(TimeSpan.FromHours(1), actual.DstOffset);
            Assert.Equal(TimeSpan.FromHours(-5), actual.RawOffset);
            Assert.Equal("America/New_York", actual.TimeZoneId);
            Assert.Equal("Eastern Daylight Time", actual.TimeZoneName);
        }
Exemplo n.º 3
0
 public CityInfoService(ITemperatureClient temperatureClient, ITimeZoneClient timeZoneClient, ApplicationDbContext dbContext)
 {
     _temperatureClient = temperatureClient;
     _timeZoneClient    = timeZoneClient;
     _dbContext         = dbContext;
 }