public async Task Should_Setup_Expectation_With_Xml_Body_When_Setup_Using_Predefined_Setup() { // Arrange const string id1 = "IP-100001"; const string id2 = "10001234"; var response = ResponseTemplate .Replace("{Id1}", id1) .Replace("{Id2}", id2); var httpResponse = HttpResponse.Create( body: new JValue(response), delay: new Delay(TimeUnit.Milliseconds, 50), headers: new Dictionary <string, string[]> { { "Content-Type", new[] { $"text/xml; charset=utf-8" } } }); var expectation = FluentExpectationBuilder.Create(httpResponse: httpResponse); var responseJson = JsonConvert.SerializeObject(httpResponse); Output.WriteLine($"responseJson: \n{responseJson}"); var expectationJson = expectation.ToString(); Output.WriteLine($"expectationJson: \n{expectationJson}"); var setup = new MockServerSetup(); setup.Expectations.Add(expectation); var setupJson = JsonConvert.SerializeObject(setup, Formatting.Indented); Output.WriteLine($"Setup json: \n{setupJson}"); // Act await MockedServer.SetupAsync(setup); await SetupResponseForOrderPlacedRequest(id1, id2); // Assert // TODO: verify setup }
public void Should_Set_Times() { // Arrange Action <IFluentExpectationBuilder> fac = expectationBuilder => expectationBuilder .OnHandling(HttpMethod.Post, request => request.WithPath("/")) .RespondOnce(HttpStatusCode.Created, resp => resp.WithDelay(1, TimeUnit.Milliseconds)); var setup = new MockServerSetup(); var builder = new FluentExpectationBuilder(setup); // Act fac(builder); var expectation = builder.Setup().Expectations.First(); var result = expectation.AsJson(); // Assert _outputHelper.WriteLine(result); result.Should() .MatchRegex(@"(?m)\s*""times"":\s*\{\s*""remainingTimes"":\s*1,\s*""unlimited"":\s*false\s*}"); }
internal FluentExpectationBuilder(MockServerSetup setup) { _setup = setup; }