public async Task IWireMockAdminApi_PostMappingAsync() { // Arrange var server = WireMockServer.StartWithAdminInterface(); var api = RestClient.For <IWireMockAdminApi>(server.Urls[0]); // Act var model = new MappingModel { Request = new RequestModel { Path = "/1" }, Response = new ResponseModel { Body = "txt", StatusCode = 200 }, Priority = 500, Title = "test" }; var result = await api.PostMappingAsync(model); // Assert Check.That(result).IsNotNull(); Check.That(result.Status).IsNotNull(); Check.That(result.Guid).IsNotNull(); var mapping = server.Mappings.Single(m => m.Priority == 500); Check.That(mapping).IsNotNull(); Check.That(mapping.Title).Equals("test"); server.Stop(); }
public ApprenticeCommitmentsInnerApiBuilder(int port) { _fixture = new Fixture(); _server = WireMockServer.StartWithAdminInterface(port, true); _registrationsInNeedOfReminders = _fixture.CreateMany <RegistrationsRemindersInvitationsResponse.Registration>(); }
public async Task WireMockServer_Should_AcceptPostMappingsWithContentTypeJsonAndAnyCharset(string contentType) { // Arrange string message = @"{ ""request"": { ""method"": ""GET"", ""url"": ""/some/thing"" }, ""response"": { ""status"": 200, ""body"": ""Hello world!"", ""headers"": { ""Content-Type"": ""text/plain"" } } }"; var stringContent = new StringContent(message); stringContent.Headers.ContentType = MediaTypeHeaderValue.Parse(contentType); var server = WireMockServer.StartWithAdminInterface(); // Act var response = await new HttpClient().PostAsync($"{server.Urls[0]}/__admin/mappings", stringContent); // Assert Check.That(response.StatusCode).Equals(HttpStatusCode.Created); Check.That(await response.Content.ReadAsStringAsync()).Contains("Mapping added"); server.Stop(); }
public async Task StartWithAdminInterfaceAndAccessWithInnerApi() { var server = WireMockServer.StartWithAdminInterface(); var api = RestClient.For <IWireMockAdminApi>(server.Urls[0]); var settings = await api.GetSettingsAsync(); var mappings = await api.GetMappingsAsync(); Assert.Empty(mappings); }
public async Task IWireMockAdminApi_GetSettingsAsync() { // Arrange var server = WireMockServer.StartWithAdminInterface(); var api = RestClient.For <IWireMockAdminApi>(server.Urls[0]); // Act var settings = await api.GetSettingsAsync(); Check.That(settings).IsNotNull(); }
public async Task IWireMockAdminApi_PutSettingsAsync() { // Arrange var server = WireMockServer.StartWithAdminInterface(); var api = RestClient.For <IWireMockAdminApi>(server.Urls[0]); // Act var settings = new SettingsModel(); var status = await api.PutSettingsAsync(settings); Check.That(status.Status).Equals("Settings updated"); }
public async Task IWireMockAdminApi_GetMappingAsync_WithBodyModelMatcherModel_WithoutMethods_ShouldReturnCorrectMappingModel() { // Arrange var guid = Guid.NewGuid(); var server = WireMockServer.StartWithAdminInterface(); var api = RestClient.For <IWireMockAdminApi>(server.Urls[0]); // Act var model = new MappingModel { Guid = guid, Request = new RequestModel { Path = "/1", Body = new BodyModel { Matcher = new MatcherModel { Name = "RegexMatcher", Pattern = "hello", IgnoreCase = true } } }, Response = new ResponseModel { Body = "world" } }; var postMappingResult = await api.PostMappingAsync(model); // Assert postMappingResult.Should().NotBeNull(); var mapping = server.Mappings.FirstOrDefault(m => m.Guid == guid); mapping.Should().NotBeNull(); var getMappingResult = await api.GetMappingAsync(guid); getMappingResult.Should().NotBeNull(); getMappingResult.Request.Body.Should().BeEquivalentTo(model.Request.Body); server.Stop(); }
public async Task IWireMockAdminApi_PostMappingsAsync() { // Arrange var server = WireMockServer.StartWithAdminInterface(); var api = RestClient.For <IWireMockAdminApi>(server.Urls[0]); // Act var model1 = new MappingModel { Request = new RequestModel { Path = "/1" }, Response = new ResponseModel { Body = "txt 1" }, Title = "test 1" }; var model2 = new MappingModel { Request = new RequestModel { Path = "/2" }, Response = new ResponseModel { Body = "txt 2" }, Title = "test 2" }; var result = await api.PostMappingsAsync(new[] { model1, model2 }); // Assert Check.That(result).IsNotNull(); Check.That(result.Status).IsNotNull(); Check.That(result.Guid).IsNull(); Check.That(server.Mappings.Where(m => !m.IsAdminInterface)).HasSize(2); server.Stop(); }
public async Task IWireMockAdminApi_PostMappingAsync_WithStatusCode(object statusCode, object expectedStatusCode) { // Arrange var server = WireMockServer.StartWithAdminInterface(); var api = RestClient.For <IWireMockAdminApi>(server.Urls[0]); // Act var model = new MappingModel { Request = new RequestModel { Path = "/1" }, Response = new ResponseModel { Body = "txt", StatusCode = statusCode }, Priority = 500, Title = "test" }; var result = await api.PostMappingAsync(model); // Assert Check.That(result).IsNotNull(); Check.That(result.Status).IsNotNull(); Check.That(result.Guid).IsNotNull(); var mapping = server.Mappings.Single(m => m.Priority == 500); Check.That(mapping).IsNotNull(); Check.That(mapping.Title).Equals("test"); var response = await mapping.ProvideResponseAsync(new RequestMessage(new UrlDetails("http://localhost/1"), "GET", "")); Check.That(response.StatusCode).Equals(expectedStatusCode); server.Stop(); }
public TrainingProviderApiBuilder(int port) { _fixture = new Fixture(); _server = WireMockServer.StartWithAdminInterface(port, true); }
public CoursesApiBuilder(int port) { _fixture = new Fixture(); _server = WireMockServer.StartWithAdminInterface(port, true); }
private FakeBusinessCentralApiBuilder(int port) { _server = WireMockServer.StartWithAdminInterface(port); }
public ApprenticeCommitmentsApiBuilder(int port) { _server = WireMockServer.StartWithAdminInterface(port, true); }
public ApprenticeLoginApiBuilder(int port) { _fixture = new Fixture(); _server = WireMockServer.StartWithAdminInterface(port, true); }
private EmployerIncentivesApiBuilder(int port) { _claims = new List <Claim>(); _server = WireMockServer.StartWithAdminInterface(port); }
public async Task StartWithAdminInterfaceAndAccessWithBrowser() { WireMockServer.StartWithAdminInterface(9090); this.OpenUrl("http://localhost:9090/__admin/mappings"); await this.WaitingForResponse(); }
public ApprenticeAccountsApiBuilder(int port) { _fixture = new Fixture(); _server = WireMockServer.StartWithAdminInterface(port, true); _apprentice = _fixture.Create <Apprentice>(); }
private FakeLearnerMatchApiBuilder(int port) { _server = WireMockServer.StartWithAdminInterface(port); }