public void GetQueryStringParametersTest() { var request = new TimeZoneRequest { Key = "abc", Location = new Location(40.7141289, -73.9614074) }; Assert.DoesNotThrow(() => request.GetQueryStringParameters()); }
public void GetQueryStringParametersWhenKeyIsEmptyTest() { var request = new TimeZoneRequest { Key = string.Empty }; var exception = Assert.Throws <ArgumentException>(() => request.GetQueryStringParameters()); Assert.AreEqual("'Key' is required", exception.Message); }
public void GetQueryStringParametersWhenLocationIsNullTest() { var request = new TimeZoneRequest { Key = "key" }; var exception = Assert.Throws <ArgumentException>(() => request.GetQueryStringParameters()); Assert.AreEqual(exception.Message, "'Location' is required"); }
public void GetQueryStringParametersWhenLocationIsNullTest() { var request = new TimeZoneRequest { Key = this.ApiKey }; var exception = Assert.Throws <ArgumentException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.IsNotNull(exception); Assert.AreEqual(exception.Message, "Location is required"); }
public void GetQueryStringParametersTest() { var request = new TimeZoneRequest { Key = "key", Location = new Coordinate(40.7141289, -73.9614074) }; var queryStringParameters = request.GetQueryStringParameters(); Assert.IsNotNull(queryStringParameters); var key = queryStringParameters.FirstOrDefault(x => x.Key == "key"); var keyExpected = request.Key; Assert.IsNotNull(key); Assert.AreEqual(keyExpected, key.Value); var language = queryStringParameters.FirstOrDefault(x => x.Key == "language"); var languageExpected = request.Language.ToCode(); Assert.IsNotNull(language); Assert.AreEqual(languageExpected, language.Value); var timestamp = queryStringParameters.FirstOrDefault(x => x.Key == "timestamp"); var timestampExpected = request.TimeStamp.DateTimeToUnixTimestamp().ToString(); Assert.IsNotNull(timestamp); Assert.AreEqual(timestampExpected, timestamp.Value); var location = queryStringParameters.FirstOrDefault(x => x.Key == "location"); var locationExpected = request.Location.ToString(); Assert.IsNotNull(location); Assert.AreEqual(locationExpected, location.Value); }