public void ThenTheResponseJsonWithElementRemovedMatches(string p0, string multilineText) { string response = (string)context[constants.responseContent]; string strippedResonse = JsonHelper.RemovePropertyFromJsonString(response, p0); JsonHelper.CompareJsonString(multilineText, strippedResonse).Should().BeTrue(); }
public void ThenTheResponseMatchesTheExpectation() { string message = ""; string expectedResult = (string)context["expectedResult"]; bool match = JsonHelper.CompareJsonString(expectedResult, (string)context[constants.responseContent], out message); match.Should().BeTrue(message); }
public void ThenTheResponseMatchesTheCreatedItem() { var createdItem = context.GetDataItems().Last(); string responseJson = (string)context[constants.responseContent]; string itemJson = JsonConvert.SerializeObject(createdItem); itemJson = JsonHelper.AddPropertyToJsonString(itemJson, "_links", "[{}]"); var result = JsonHelper.CompareJsonString(itemJson, responseJson); result.Should().BeTrue("Because the data returned should match the created item"); }
public void ThenTheResponseJsonHasCollectionWithAnItemMatching(string p0, string multilineText) { bool bMatch = false; dynamic responseJson = JsonConvert.DeserializeObject <dynamic>((string)context[constants.responseContent]); dynamic includedCollection = responseJson[p0]; foreach (var item in includedCollection) { string json = Newtonsoft.Json.JsonConvert.SerializeObject(item); bMatch = JsonHelper.CompareJsonString(json, multilineText); if (bMatch) { break; } } bMatch.Should().BeTrue(); }
public void ThenTheResponseIncludesAllItemsOfType(string p0) { string responses = ""; int numberOfItems = context.GetDataItems().Count; int itemCount = 0; foreach (var item in context.GetDataItems()) { bool lastItem = ++itemCount == numberOfItems; responses += $"{JsonConvert.SerializeObject(item)}{(lastItem ? "" : ",")}"; } string itemJson = $"[{responses}]"; string responseJson = (string)context[constants.responseContent]; var result = JsonHelper.CompareJsonString(itemJson, responseJson); result.Should().BeTrue("Because the data returned should include all the created items"); }
public void ThenTheResponseJsonMatches(string multilineText) { // replace any tokens in the expected response foreach (var item in context.GetTokens()) { //TODO standardise token use if (item.Key.Contains("__")) { multilineText = multilineText.Replace($"{item.Key}", item.Value); } else { multilineText = multilineText.Replace($"{tokenChar}{item.Key}{tokenChar}", item.Value); } } string message = ""; bool match = JsonHelper.CompareJsonString(multilineText, (string)context[constants.responseContent], out message); match.Should().BeTrue(message); }