/// <summary> /// Verifies the service implementation feature. /// </summary> /// <param name="context">The Interop service context</param> /// <param name="info">out parameter to return violation information when rule does not pass</param> /// <returns>true if the service implementation feature passes; false otherwise</returns> public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info) { if (context == null) { throw new ArgumentNullException("context"); } bool?passed = null; info = null; var svcStatus = ServiceStatus.GetInstance(); var entitySetUrls = MetadataHelper.GetEntitySetURLs(); var entitySetUrl = entitySetUrls[0]; string url = svcStatus.RootURL.TrimEnd('/') + "/" + entitySetUrl; int actualNum = JsonParserHelper.GetEntitiesCountFromFeed(url, svcStatus.DefaultHeaders); url = string.Format("{0}?$skip={1}", url, actualNum - 1); var resp = WebHelper.Get(new Uri(url), string.Empty, RuleEngineSetting.Instance().DefaultMaximumPayloadSize, svcStatus.DefaultHeaders); var detail = new ExtensionRuleResultDetail("ServiceImpl_SystemQueryOptionSkip", url, HttpMethod.Get, string.Empty); info = new ExtensionRuleViolationInfo(new Uri(url), string.Empty, detail); if (null != resp && HttpStatusCode.OK == resp.StatusCode) { JObject jObj = JObject.Parse(resp.ResponsePayload); JArray jArr = jObj.GetValue("value") as JArray; passed = 1 == jArr.Count; } else { passed = false; } return(passed); }
/// <summary> /// Verifies the service implementation feature. /// </summary> /// <param name="context">The Interop service context</param> /// <param name="info">out parameter to return violation information when rule does not pass</param> /// <returns>true if the service implementation feature passes; false otherwise</returns> public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info) { if (context == null) { throw new ArgumentNullException("context"); } bool?passed = null; info = null; var svcStatus = ServiceStatus.GetInstance(); var pagingLimitEntitySetUrls = MetadataHelper.GetPagingLimitEntitySetURLs(); if (null == pagingLimitEntitySetUrls || !pagingLimitEntitySetUrls.Any()) { return(passed); } var pagingLimitEntitySetUrl = pagingLimitEntitySetUrls.First(); string url = svcStatus.RootURL.TrimEnd('/') + "/" + pagingLimitEntitySetUrl; int actualNum = JsonParserHelper.GetEntitiesCountFromFeed(url); var resp = WebHelper.Get(new Uri(url), Constants.V4AcceptHeaderJsonFullMetadata, RuleEngineSetting.Instance().DefaultMaximumPayloadSize, context.RequestHeaders); var detail = new ExtensionRuleResultDetail("ServiceImpl_SystemQueryOptionSkipToken", url, HttpMethod.Get, string.Empty); detail.URI = url; detail.ResponsePayload = resp.ResponsePayload; detail.ResponseHeaders = resp.ResponseHeaders; detail.HTTPMethod = "GET"; detail.ResponseStatusCode = resp.StatusCode.ToString(); info = new ExtensionRuleViolationInfo(new Uri(url), string.Empty, detail); if (null != resp && HttpStatusCode.OK == resp.StatusCode) { var jObj = JObject.Parse(resp.ResponsePayload); var jArr = jObj.GetValue("value") as JArray; passed = jArr.Count < actualNum; } else { passed = false; } return(passed); }
/// <summary> /// Verifies the service implementation feature. /// </summary> /// <param name="context">The Interop service context</param> /// <param name="info">out parameter to return violation information when rule does not pass</param> /// <returns>true if the service implementation feature passes; false otherwise</returns> public override bool?Verify(ServiceContext context, out ExtensionRuleViolationInfo info) { if (context == null) { throw new ArgumentNullException("context"); } bool?passed = null; info = null; var svcStatus = ServiceStatus.GetInstance(); var entitySetUrls = MetadataHelper.GetEntitySetURLs(); var entitySetUrl = entitySetUrls[0]; string url = svcStatus.RootURL.TrimEnd('/') + "/" + entitySetUrl; int actualNum = JsonParserHelper.GetEntitiesCountFromFeed(url, svcStatus.DefaultHeaders); url = string.Format("{0}/$count", url); var resp = WebHelper.Get(new Uri(url), string.Empty, RuleEngineSetting.Instance().DefaultMaximumPayloadSize, svcStatus.DefaultHeaders); var detail = new ExtensionRuleResultDetail("ServiceImpl_SystemQueryOptionCount", url, HttpMethod.Get, string.Empty); detail.URI = url; detail.ResponsePayload = resp.ResponsePayload; detail.ResponseHeaders = resp.ResponseHeaders; detail.HTTPMethod = "GET"; detail.ResponseStatusCode = resp.StatusCode.ToString(); info = new ExtensionRuleViolationInfo(new Uri(url), string.Empty, detail); if (null != resp && HttpStatusCode.OK == resp.StatusCode) { passed = Convert.ToInt32(resp.ResponsePayload) == actualNum; if (passed == false) { detail.ErrorMessage = "The response did not return the correct number"; } } else { detail.ErrorMessage = "The Response returned an error: " + resp.StatusCode.ToString(); passed = false; } return(passed); }