public override IEnumerator <WebTestRequest> GetRequestEnumerator() { //Validate correct server response when send lang=en yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f))); //Validate correct server response when send lang=th yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, "th"))); //Validate correct server response when send lang=en,th yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, "en,th"))); //Validate correct server response when send foreign language yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, "ru"))); //Validate correct server response when send foreign language yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, "sweden"))); }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { //Get first server response and save it with default offset yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.145f, 10000))); var firstResponse = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); //Get next page from current step yield return(requests.Get(ThaiUrls.thaiApi + firstResponse.next_parameter)); var nextResponse = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); //Get server response with offset = 15 and compare docs collection with nextResponse docs collection. //It should be equals. yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.145f, 10000, offset: 15))); var firstOffserResponse = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); firstOffserResponse.docs.ShouldBeEquivalentTo(nextResponse.docs); //Get previous page from firstOffserResponse and docs collection with firstResponse docs collection. //It should be equals. yield return(requests.Get(ThaiUrls.thaiApi + firstOffserResponse.prev_parameter)); var prevResponse = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); prevResponse.docs.ShouldBeEquivalentTo(firstResponse.docs); //Validate correct server response when offset is float (15.7) yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, offset: 0.7f), 200)); //Validate correct server response when offset < 0 yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, offset: -25), 400)); //Get first server response and previous page after that yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.145f, 10000))); firstResponse = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); yield return(requests.Get(ThaiUrls.thaiApi + firstResponse.prev_parameter)); }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { //Validate that default sort is Fuzzy yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, radius: 100, sort: null))); var response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.sort_strategy.ShouldBeEquivalentTo("f"); AddCommentToResult(Context.LastResponse.BodyString); //Validate that default sort is Fuzzy yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, radius: 100, sort: "f"))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.sort_strategy.ShouldBeEquivalentTo("f"); AddCommentToResult(Context.LastResponse.BodyString); //Validate that server response contains distance sort when send sort = d yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, radius: 100, sort: "d"))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.sort_strategy.ShouldBeEquivalentTo("d"); AddCommentToResult(Context.LastResponse.BodyString); //Validate correct server response when send inexistent type of sort yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, sort: "y"), 400)); //Validate correct server response when send inexistent type of sort yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, sort: "99"), 400)); }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { //Validate that default limit equals 15 float limit = 15; yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000))); var response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.item_per_page.ShouldBeEquivalentTo(limit); if (response.item_found > limit) { response.docs.Count.ShouldBeEquivalentTo(limit); } //Validate correct behaviour when increase limit to 100 limit = 100; yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, limit: limit))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.item_per_page.ShouldBeEquivalentTo(limit); if (response.item_found > limit) { response.docs.Count.ShouldBeEquivalentTo(limit); } //Validate correct behaviour when increase limit to 1000 limit = 1000; yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, limit: limit))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.item_per_page.ShouldBeEquivalentTo(limit); if (response.item_found > limit) { response.docs.Count.ShouldBeEquivalentTo(limit); } //Validate correct behaviour when set limit as 0 limit = 0; yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, limit: limit))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.item_per_page.ShouldBeEquivalentTo(limit); if (response.item_found > limit) { response.docs.Count.ShouldBeEquivalentTo(limit); } //Validate correct behaviour when set limit as 15.7 limit = 15.7f; yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, limit: limit), 400)); //Validate correct behaviour when set limit as -40 limit = -40; yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000, limit: limit), 400)); }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { //Validate that it works with correct coordinate and default radius //And validate that response contains the same radius yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f))); var response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.radius.ShouldBeEquivalentTo("5"); //Validate that it works with correct coordinate and radius = 15 //And validate that response contains the same radius yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 15))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.radius.ShouldBeEquivalentTo("15"); //Validate that it works with correct coordinate and float radius = 15.715 //And validate that response contains the same radius yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 15.715f))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.radius.ShouldBeEquivalentTo("15.715"); //Validate that it works with correct coordinate and float radius = 0.715 //And validate that response contains the same radius yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 0.715f))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.radius.ShouldBeEquivalentTo("0.715"); //Validate correct server response when radius = 0 yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 0))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.radius.ShouldBeEquivalentTo("0"); //Validate correct server response when radius < 0 yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, -12), 400)); //Validate correct server response when radius is null yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, null), 200)); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.radius.ShouldBeEquivalentTo("5"); //Validate that item_found1 > item_found2 when radius1 > radius2 yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 10000))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.radius.ShouldBeEquivalentTo("10000"); var item_found1 = response.item_found; AddCommentToResult(Context.LastResponse.BodyString); yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f, 1000))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.radius.ShouldBeEquivalentTo("1000"); var item_found2 = response.item_found; AddCommentToResult(Context.LastResponse.BodyString); item_found1.Should().BeGreaterThan(item_found2); }
public override IEnumerator <WebTestRequest> GetRequestEnumerator() { //Validate that it works with correct coordinate //And validate that response contains the same coordinate yield return(requests.Get(ThaiUrls.ReverseGeocode(5.668142f, 101.144964f))); var response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.lat.ShouldBeEquivalentTo(5.668142); response.lng.ShouldBeEquivalentTo(Math.Round(101.144964, 3)); //Validate that it works with correct coordinate(integer type) //And validate that response contains the same coordinate yield return(requests.Get(ThaiUrls.ReverseGeocode(5, 101))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.lat.ShouldBeEquivalentTo(5); response.lng.ShouldBeEquivalentTo(101); //Validate that it works with correct coordinate(latitude < 0) //And validate that response contains the same coordinate yield return(requests.Get(ThaiUrls.ReverseGeocode(-15, 101))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.lat.ShouldBeEquivalentTo(-15); response.lng.ShouldBeEquivalentTo(101); //Validate that it works with correct coordinate(longitude < 0) //And validate that response contains the same coordinate yield return(requests.Get(ThaiUrls.ReverseGeocode(5, -101))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.lat.ShouldBeEquivalentTo(5); response.lng.ShouldBeEquivalentTo(-101); //Validate that it works with correct coordinate(latitude < 0 & longitude < 0) //And validate that response contains the same coordinate yield return(requests.Get(ThaiUrls.ReverseGeocode(-15, -101))); response = JsonConvert.DeserializeObject <Response>(Context.LastResponse.BodyString); response.lat.ShouldBeEquivalentTo(-15); response.lng.ShouldBeEquivalentTo(-101); //Validate correct server response when latitude is missing yield return(requests.Get(ThaiUrls.ReverseGeocode(null, -101), 400)); //Validate correct server response when longitude is missing yield return(requests.Get(ThaiUrls.ReverseGeocode(-15, null), 400)); //Validate correct server response when latitude is incorrect (latitude > 90 ) yield return(requests.Get(ThaiUrls.ReverseGeocode(100, -101), 400)); //Validate correct server response when latitude is incorrect (latitude < -90 ) yield return(requests.Get(ThaiUrls.ReverseGeocode(-100, -101), 400)); //Validate correct server response when longitude is incorrect (longitude > 180 ) yield return(requests.Get(ThaiUrls.ReverseGeocode(10, 200), 400)); //Validate correct server response when longitude is incorrect (longitude < -180 ) yield return(requests.Get(ThaiUrls.ReverseGeocode(10, -200), 400)); }