예제 #1
0
        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}");
        }
예제 #2
0
        public void EndpointFilterFactory_ShouldParse_EndpointOnly()
        {
            // Arrange

            // Act
            var endpointFilter = EndpointFilterFactory.CreateEndpointFilter("/api/Pets");

            // Assert
            endpointFilter.Should().BeEquivalentTo(new EndpointFilter(null, "/api/Pets", "/api/Pets"));
        }
예제 #3
0
        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"));
        }
예제 #4
0
        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();
        }
예제 #5
0
        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();
        }
예제 #6
0
        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);
        }
예제 #7
0
 public void EndpointFilterFactory_ShouldParseEndpoints(string endpoint)
 {
     // Act
     Assert.DoesNotThrow(() => EndpointFilterFactory.CreateEndpointFilter(endpoint));
 }