private void Assert(string expected, Action <IFluentBodyBuilder> factory) { var builder = new FluentBodyBuilder(); factory(builder); var resultJToken = builder.Build(); var expectedJToken = JObject.Parse(expected); var envelope = new JObject(new JProperty("body", "{CONTENT}")); var body = envelope.Children() .OfType <JProperty>() .First(jp => jp.Name == "body").Value .Value <JValue>(); body.Replace(resultJToken); var result = envelope.ToString(Formatting.Indented); _outputHelper.WriteLine($"Expected:\n\n{expected}\n"); _outputHelper.WriteLine($"Actual:\n\n{result}\n"); envelope.Should().BeEquivalentTo(expectedJToken); // JsonAssertionExtensions.Should(envelope).BeEquivalentTo(expectedJToken); }
public IFluentHttpRequestBuilder WithContent([NotNull] Action <IFluentBodyBuilder> contentFactory) { var builder = new FluentBodyBuilder(); contentFactory(builder); _body = builder.Build(); return(this); }
public IFluentHttpRequestBuilder WithBody(Body.BodyType type, string value) { var builder = new FluentBodyBuilder(); switch (type) { case Body.BodyType.JSON: builder.WithExactJson(value); break; case Body.BodyType.JSON_PATH: builder.MatchingJsonPath(value); break; case Body.BodyType.JSON_SCHEMA: builder.MatchingJsonSchema(value); break; case Body.BodyType.XML: builder.WithXmlContent(value); break; case Body.BodyType.XPATH: builder.MatchingXPath(value); break; case Body.BodyType.XML_SCHEMA: builder.MatchingXmlSchema(value); break; case Body.BodyType.STRING: builder.WithExactContent(value); break; } _body = builder.Build(); return(this); }