Skip to content

Commit

Permalink
Added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
RicoSuter committed Mar 12, 2016
1 parent eb8d008 commit 2af58a1
Show file tree
Hide file tree
Showing 4 changed files with 701 additions and 648 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Compile Include="WebApiToSwaggerGenerator\Attributes\ComplexParametersTests.cs" />
<Compile Include="WebApiToSwaggerGenerator\Attributes\PrimitivePathParametersTests.cs" />
<Compile Include="WebApiToSwaggerGenerator\Attributes\PrimitiveQueryParametersTests.cs" />
<Compile Include="WebApiToSwaggerGenerator\Attributes\RouteInheritanceTests.cs" />
<Compile Include="WebApiToSwaggerGenerator\GeneralTests.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Linq;
using System.Web.Http;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NSwag.CodeGeneration.SwaggerGenerators.WebApi;

namespace NSwag.CodeGeneration.Tests.WebApiToSwaggerGenerator.Attributes
{
// See https://github.com/NSwag/NSwag/issues/48

//[TestClass]
public class RouteInheritanceTests
{
//[TestMethod]
public void When_route_is_on_inherited_parent_class_then_it_is_used_for_swagger_generation()
{
//// Arrange
var generator = new SwaggerGenerators.WebApi.WebApiToSwaggerGenerator(new WebApiToSwaggerGeneratorSettings());

//// Act
var service = generator.GenerateForController<MyController>();

//// Assert
Assert.AreEqual("api/My/Foo", service.Operations.First().Path);
}

[RoutePrefix("api/My")]
public class MyController : BaseController
{

}

public class BaseController : ApiController
{
[Route("Foo")]
public string Bar()
{
return "foo";
}
}
}
}
Loading

0 comments on commit 2af58a1

Please sign in to comment.