public void EndpointFilterFactory_ShouldThrowException_DueToInvalidFilterFormat(string endpointFilterString) { // Act var exception = Assert.Throws <ArgumentException>(() => EndpointFilterFactory.CreateEndpointFilter(endpointFilterString)); // Assert exception.Message.Should().BeEquivalentTo($"Invalid format of endpoint filter. Must be POST:/api/Pet or :/api/Pet or /api/Pet. Current format: {endpointFilterString}"); }
public void EndpointFilterFactory_ShouldParse_EndpointOnly() { // Arrange // Act var endpointFilter = EndpointFilterFactory.CreateEndpointFilter("/api/Pets"); // Assert endpointFilter.Should().BeEquivalentTo(new EndpointFilter(null, "/api/Pets", "/api/Pets")); }
public void EndpointFilterFactory_ShouldParse_MethodColonAndEndpoint() { // Arrange // Act var endpointFilter = EndpointFilterFactory.CreateEndpointFilter("POST:/api/Pets"); // Assert endpointFilter.Should().BeEquivalentTo(new EndpointFilter("POST", "/api/Pets", "POST:/api/Pets")); }
public void EndpointFilterFactory_Should_CheckWildcardOnStart() { // Arrange var endpointFilter = EndpointFilterFactory.CreateEndpointFilter("/*}"); var endpoints = GetPetstoreEndpoints(); // Act var filteredEndpoints = endpoints.Where(p => endpointFilter.MatchEndpoint(p.HttpMethod, p.EndpointPath)).ToList(); // Assert filteredEndpoints.All(x => x.EndpointPath.EndsWith("}")).Should().BeTrue(); }
public void EndpointFilter_Should_GetEndpointsOnlyWithHttpMethodAndWildcardedEndpoint2() { // Arrange var endpointFilter = EndpointFilterFactory.CreateEndpointFilter("POST:/api*}"); List <Endpoint> endpoints = GetPetstoreEndpoints(); // Act var filteredEndpoints = endpoints.Where(x => endpointFilter.MatchEndpoint(x.HttpMethod, x.EndpointPath)).ToList(); // Assert filteredEndpoints.All(x => x.HttpMethod == "POST" && x.HttpMethod.StartsWith("}")).Should().BeTrue(); }
public void EndpointFilterFactory_Should_GetAllEndpoints() { // Arrange var endpointFilter = EndpointFilterFactory.CreateEndpointFilter("/*"); var endpoints = GetPetstoreEndpoints(); // Act var filteredEndpoints = endpoints.Where(p => endpointFilter.MatchEndpoint(p.HttpMethod, p.EndpointPath)).ToList(); // Assert filteredEndpoints.Should().HaveCount(endpoints.Count); filteredEndpoints.Should().BeEquivalentTo(endpoints); }
public void EndpointFilterFactory_ShouldParseEndpoints(string endpoint) { // Act Assert.DoesNotThrow(() => EndpointFilterFactory.CreateEndpointFilter(endpoint)); }