public void Should_Setup_Multiple_Expectationst_At_Once() { var builder = new FluentExpectationBuilder(); var setup = builder .OnHandling(HttpMethod.Delete, request => request .WithContent(content => content.MatchingXPath("//id")) .WithPath("post") .EnableEncryption() .KeepConnectionAlive()) .RespondWith(HttpStatusCode.Accepted, response => response .ConfigureConnection(opt => opt.Build()) .ConfigureHeaders(opt => { opt.AddContentType(CommonContentType.Json); opt.Add("Basic", "cqwr"); }) .WithStatusCode(100) .WithBody("hello world!") .WithDelay(1, TimeUnit.Minutes)) .And .OnHandling( HttpMethod.Delete, request => request .WithPath("post") .EnableEncryption() .KeepConnectionAlive()) .RespondWith(HttpStatusCode.Accepted, response => response .WithBody(Encoding.UTF8.GetBytes("ewogICAgIk5hbWUiOiAiQWxleCIKfQ=="))) .Setup(); var json = setup.ToString(); _output.WriteLine(json); }
public void Should_Match_Any_Request_With_Method(string method) { // Arrange var builder = new FluentExpectationBuilder(); // Act builder.OnHandling(new HttpMethod(method)) .RespondWith(HttpStatusCode.Created); var expectation = builder.Setup().Expectations.First(); var result = expectation.AsJson(); // Assert _outputHelper.WriteLine(result); result.Should().MatchRegex($@"(?smi)""httpRequest"":.*{{.*""method"".*:.*""{method}"".*}}.*,"); }