public void GetOpenApiDocument_WithNullForDocumentName_ThrowsException() { var sut = new OpenApiService(_swaggerProvider); Action action = () => sut.GetOpenApiDocument(null); action.Should().Throw <ArgumentNullException>().And.ParamName.Should().Be("documentName"); }
public void GetOpenApiDocument_WithInvalidDataForDocumentName_ThrowsException(string documentName) { var sut = new OpenApiService(_swaggerProvider); Action action = () => sut.GetOpenApiDocument(documentName); action.Should().Throw <ArgumentException>().And.ParamName.Should().Be("documentName"); }
public void GetOpenApiDocument_PassesOnDocumentName() { var documentName = "myDocumentName"; var openApiDocument = new OpenApiDocument(); A.CallTo(() => _swaggerProvider.GetSwagger(documentName, null, null)).Returns(openApiDocument); var sut = new OpenApiService(_swaggerProvider); var document = sut.GetOpenApiDocument(documentName); A.CallTo(() => _swaggerProvider.GetSwagger(documentName, null, null)).MustHaveHappenedOnceExactly(); document.Should().NotBeNull(); }
public void GetOpenApiDocument_ForHostAndBasePath_PassesOnCorrectHostAndBasePath(string host, string basePath, string expectedHost, string expectedBasePath) { const string documentName = "myDocumentName"; var openApiDocument = new OpenApiDocument(); A.CallTo(() => _swaggerProvider.GetSwagger(documentName, A <string> ._, A <string> ._)).Returns(openApiDocument); var sut = new OpenApiService(_swaggerProvider); var document = sut.GetOpenApiDocument(documentName, host, basePath); document.Should().NotBeNull(); A.CallTo(() => _swaggerProvider.GetSwagger(documentName, expectedHost, expectedBasePath)).MustHaveHappenedOnceExactly(); }
public void GetOpenApiDocument_ReturnsCorrectDocument() { const string documentName = "myDocumentName"; var openApiDocument = new OpenApiDocument { Info = new OpenApiInfo { Description = "Test document", Version = "v1", Title = "Test" } }; A.CallTo(() => _swaggerProvider.GetSwagger(documentName, null, null)).Returns(openApiDocument); var sut = new OpenApiService(_swaggerProvider); var document = sut.GetOpenApiDocument(documentName); document.Should().BeEquivalentTo(openApiDocument); }