public async Task JsonData_ShouldDeserializeAsyncWithCorrectCity(Provider source, string expectedValue) { // Arrange using var jsonStream = TestData.GetJsonStream(source); // Act var result = await GeolocationSerializer.DeserializeAsync(source, jsonStream, CancellationToken.None); // Assert Assert.AreEqual(expectedValue, result?.City); }
public void JsonData_ShouldDeserializeWithCorrectCity(Provider source, string expectedValue) { // Arrange var json = TestData.GetJson(source); // Act var result = GeolocationSerializer.Deserialize(source, json); // Assert Assert.AreEqual(expectedValue, result?.City); }
public void JsonData_WhenInvalidJson_ShouldThrownJsonException() { // Arrange var json = TestData.GetJson("Invalid"); // Act Action action = () => { var result = GeolocationSerializer.Deserialize(Provider.AbstractApi, json); }; // Assert Assert.ThrowsException <JsonException>(action); }
public async Task JsonData_WhenInvalidJson_ShouldThrownJsonExceptionAsync() { // Arrange using var jsonStream = TestData.GetJsonStream("Invalid"); // Act Func <Task> action = async() => { var result = await GeolocationSerializer.DeserializeAsync(Provider.AbstractApi, jsonStream, CancellationToken.None); }; // Assert await Assert.ThrowsExceptionAsync <JsonException>(action); }
public void JsonData_ShouldDeserializeWithData(Provider source) { // Arrange var json = TestData.GetJson(source); // Act var result = GeolocationSerializer.Deserialize(source, json); // Assert Assert.IsNotNull(result); Assert.IsNotNull(result.City); Assert.IsNotNull(result.RegionCode); Assert.IsNotNull(result.RegionName); Assert.IsNotNull(result.CountryCode); Assert.IsNotNull(result.CountryName); Assert.IsNotNull(result.Latitude); Assert.IsNotNull(result.Longitude); }