public void GetQueryStringParametersTest() { var request = new ImageSearchRequest { Key = "abc", SearchEngineId = "abc", Query = "abc" }; Assert.DoesNotThrow(() => request.GetQueryStringParameters()); }
public void GetQueryStringParametersWhenKeyIsStringEmptyTest() { var request = new ImageSearchRequest { Key = string.Empty }; var exception = Assert.Throws <ArgumentException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.AreEqual(exception.Message, "Key is required"); }
public void GetQueryStringParametersWhenQueryIsNullTest() { var request = new ImageSearchRequest { Key = "abc", Query = null }; var exception = Assert.Throws <ArgumentException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.AreEqual(exception.Message, "Query is required"); }
public void GetQueryStringParametersWhenSearchEngineIdIsNullTest() { var request = new ImageSearchRequest { Key = this.ApiKey, Query = "google", SearchEngineId = null }; var exception = Assert.Throws <ArgumentException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.AreEqual(exception.Message, "SearchEngineId is required"); }
public void GetQueryStringParametersWhenOptionsNumberIsGreaterThanNineTest() { var request = new ImageSearchRequest { Key = "abc", Query = "google", SearchEngineId = "abc", Options = { Number = 11 } }; var exception = Assert.Throws <InvalidOperationException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.AreEqual(exception.Message, "Number must be between 1 and 10"); }
public void GetQueryStringParametersWhenSafetyLevelInterfaceLanguageIsNotSupportedTest() { var request = new ImageSearchRequest { Key = "abc", Query = "google", SearchEngineId = "abc", Options = { SafetyLevel = SafetyLevel.Medium, InterfaceLanguage = Language.Afrikaans } }; var exception = Assert.Throws <InvalidOperationException>(() => { var parameters = request.GetQueryStringParameters(); Assert.IsNull(parameters); }); Assert.AreEqual(exception.Message, $"SafetyLevel is not allowed for specified InterfaceLanguage: {request.Options.InterfaceLanguage}"); }