Beispiel #1
0
        public void UrlObjectConverter_ProducesExpectedRawUrlFromHostBasePathAndPath(string host, string basePath, string path, string expectedRawUrl)
        {
            UrlObjectConverter converter = new UrlObjectConverter(new DefaultValueFactory());
            PostmanUrl         result    = converter.Convert(path, new List <IParameter>(), host, basePath);

            Assert.Equal(expectedRawUrl, result.Raw);
        }
Beispiel #2
0
        public void UrlObjectConverter_ProducesExpectedHost(string host, string expectedhost)
        {
            UrlObjectConverter converter = new UrlObjectConverter(new DefaultValueFactory());
            PostmanUrl         result    = converter.Convert(_validPath, _validParameters, host, _validPath);

            Assert.Equal(expectedhost, result.Host);
        }
Beispiel #3
0
        public void UrlObjectConverter_ProducesExpectedRawUrl()
        {
            UrlObjectConverter converter = new UrlObjectConverter(new DefaultValueFactory());
            PostmanUrl         result    = converter.Convert(_validPath, _validParameters, _validHost, _validBasePath);

            Assert.Equal("http://mysite.com/api/Values/postFormDataEndpoint/:id?filter={{filter}}&page={{page}}", result.Raw);
        }
Beispiel #4
0
        public void UrlObjectConverter_ProducesExpectedPathSegments(string basepath, string path, string[] expectedSegments)
        {
            UrlObjectConverter converter = new UrlObjectConverter(new DefaultValueFactory());
            PostmanUrl         result    = converter.Convert(path, new List <IParameter>(), _validHost, basepath);

            Assert.Equal(expectedSegments, result.Path);
        }
Beispiel #5
0
        public void UrlObjectConverter_ProducesExpectedPath()
        {
            UrlObjectConverter converter = new UrlObjectConverter(new DefaultValueFactory());
            PostmanUrl         result    = converter.Convert(_validPath, _validParameters, _validHost, _validBasePath);

            Assert.Equal(new string[] { "api", "Values", "postFormDataEndpoint", ":id" }, result.Path);
        }
Beispiel #6
0
        public void UrlObjectConverter_ProducesTheSameNumberOfVariablesAsUrlParameters()
        {
            int expectedTotal            = _validParameters.Count(p => p.In == SwashbuckleParameterTypeConstants.Query || p.In == SwashbuckleParameterTypeConstants.Path);
            UrlObjectConverter converter = new UrlObjectConverter(new DefaultValueFactory());
            PostmanUrl         result    = converter.Convert(_validPath, _validParameters, _validHost, _validBasePath);

            Assert.Equal(expectedTotal, result.Variables.Count);
        }
Beispiel #7
0
        public void UrlObjectConverter_ProducesCorrectQueryParameters()
        {
            int expectedTotal = _validParameters.Count(p => p.In == SwashbuckleParameterTypeConstants.Query);

            UrlObjectConverter converter = new UrlObjectConverter(new DefaultValueFactory());
            PostmanUrl         result    = converter.Convert(_validPath, _validParameters, _validHost, _validBasePath);

            foreach (PostmanQueryParam resultParam in result.QueryParams)
            {
                Assert.NotNull(resultParam.Key);
                Assert.NotNull(resultParam.Value);
                Assert.NotNull(resultParam.Description);
                var sourceParam = _validParameters.First(x => x.Name == resultParam.Key);
                Assert.Equal(sourceParam.Name, resultParam.Key);
                Assert.Equal(resultParam.Description.Content, sourceParam.Description);
            }
        }