private void VerifyUnrecoverableHttpError(int status) { _ep = MakeProcessor(_config); Event e = EventFactory.Default.NewIdentifyEvent(_user); _ep.SendEvent(e); FlushAndGetEvents(Response.Create().WithStatusCode(status)); _server.ResetLogEntries(); _ep.SendEvent(e); _ep.Flush(); ((DefaultEventProcessor)_ep).WaitUntilInactive(); foreach (LogEntry le in _server.LogEntries) { Assert.True(false, "Should not have sent an HTTP request"); } }
public async Task FluentMockServer_Should_reset_requestlogs() { // given _server = FluentMockServer.Start(); // when await new HttpClient().GetAsync("http://localhost:" + _server.Ports[0] + "/foo"); _server.ResetLogEntries(); // then Check.That(_server.LogEntries).IsEmpty(); }
public async Task FluentMockServer_Should_respond_to_valid_matchers_when_sent_json() { // Assign var validMatchersForHelloServerJsonMessage = new List <object[]> { new object[] { new WildcardMatcher("*Hello server*"), "application/json" }, new object[] { new WildcardMatcher("*Hello server*"), "text/plain" }, new object[] { new ExactMatcher(jsonRequestMessage), "application/json" }, new object[] { new ExactMatcher(jsonRequestMessage), "text/plain" }, new object[] { new RegexMatcher("Hello server"), "application/json" }, new object[] { new RegexMatcher("Hello server"), "text/plain" }, new object[] { new JsonPathMatcher("$..[?(@.message == 'Hello server')]"), "application/json" }, new object[] { new JsonPathMatcher("$..[?(@.message == 'Hello server')]"), "text/plain" } }; _server = FluentMockServer.Start(); foreach (var item in validMatchersForHelloServerJsonMessage) { string path = $"/foo_{Guid.NewGuid()}"; _server .Given(Request.Create().WithPath(path).WithBody((IMatcher)item[0])) .RespondWith(Response.Create().WithBody("Hello client")); // Act var content = new StringContent(jsonRequestMessage, Encoding.UTF8, (string)item[1]); var response = await new HttpClient().PostAsync("http://localhost:" + _server.Ports[0] + path, content); // Assert var responseString = await response.Content.ReadAsStringAsync(); Check.That(responseString).Equals("Hello client"); _server.ResetMappings(); _server.ResetLogEntries(); } }
public void Dispose() { _server.Stop(); _server.ResetLogEntries(); //MetricsManager.Shutdown(); }