Skip to content

Commit e3986d3

Browse files
Chris Martinezcommonsensesoftware
authored andcommitted
Add acceptance tests
1 parent 8d8efba commit e3986d3

File tree

74 files changed

+1691
-33
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1691
-33
lines changed

test/Microsoft.AspNet.WebApi.Acceptance.Tests/OData/Basic/BasicAcceptanceTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected BasicAcceptanceTest()
4040
}
4141

4242
[Fact]
43-
public async Task service_document_should_return_400_for_unsupported_url_api_version()
43+
public async Task then_service_document_should_return_400_for_unsupported_url_api_version()
4444
{
4545
// arrange
4646
var requestUrl = $"v4";
@@ -55,7 +55,7 @@ public async Task service_document_should_return_400_for_unsupported_url_api_ver
5555
}
5656

5757
[Fact]
58-
public async Task metadata_should_return_400_for_unsupported_url_api_version()
58+
public async Task then_X24metadata_should_return_400_for_unsupported_url_api_version()
5959
{
6060
// arrange
6161

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/AcceptanceTest.cs

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55
using Builder;
66
using Extensions.DependencyInjection;
77
using Hosting;
8-
using Microsoft.AspNetCore.Mvc.Razor;
98
using System;
109
using System.Collections.Generic;
1110
using System.IO;
12-
using System.Linq;
1311
using System.Net.Http;
1412
using System.Reflection;
1513
using TestHost;
1614
using Versioning;
1715
using Xunit;
18-
using static Microsoft.CodeAnalysis.MetadataReference;
1916
using static Microsoft.Extensions.DependencyInjection.ServiceDescriptor;
20-
using static System.Reflection.Assembly;
2117

2218
[Trait( "Framework", "ASP.NET Core" )]
2319
public abstract partial class AcceptanceTest : IDisposable
@@ -66,7 +62,7 @@ TestServer CreateServer()
6662
{
6763
var builder = new WebHostBuilder()
6864
.Configure( app => app.UseMvc( OnConfigureRoutes ).UseMvcWithDefaultRoute() )
69-
.ConfigureServices( OnConfigureServices )
65+
.ConfigureServices( OnDefaultConfigureServices )
7066
.UseContentRoot( GetContentRoot() );
7167

7268
return new TestServer( builder );
@@ -79,33 +75,15 @@ HttpClient CreateAndInitializeHttpClient()
7975
return newClient;
8076
}
8177

82-
void OnConfigureServices( IServiceCollection services )
78+
void OnDefaultConfigureServices( IServiceCollection services )
8379
{
8480
var partManager = new ApplicationPartManager();
8581

86-
partManager.FeatureProviders.Add( filteredControllerTypes );
87-
partManager.ApplicationParts.Add( new AssemblyPart( GetType().GetTypeInfo().Assembly ) );
82+
OnConfigurePartManager( partManager );
8883
services.Add( Singleton( partManager ) );
8984
services.AddMvc();
9085
services.AddApiVersioning( OnAddApiVersioning );
91-
services.Configure<RazorViewEngineOptions>( options =>
92-
{
93-
options.CompilationCallback += context =>
94-
{
95-
var assembly = GetType().GetTypeInfo().Assembly;
96-
var assemblies = assembly.GetReferencedAssemblies().Select( x => CreateFromFile( Load( x ).Location ) ).ToList();
97-
98-
assemblies.Add( CreateFromFile( Load( new AssemblyName( "mscorlib" ) ).Location ) );
99-
#if NET461
100-
assemblies.Add( CreateFromFile( Load( new AssemblyName( "netstandard" ) ).Location ) );
101-
#else
102-
assemblies.Add( CreateFromFile( Load( new AssemblyName( "System.Private.Corelib" ) ).Location ) );
103-
#endif
104-
assemblies.Add( CreateFromFile( Load( new AssemblyName( "System.Dynamic.Runtime" ) ).Location ) );
105-
assemblies.Add( CreateFromFile( Load( new AssemblyName( "Microsoft.AspNetCore.Razor" ) ).Location ) );
106-
context.Compilation = context.Compilation.AddReferences( assemblies );
107-
};
108-
} );
86+
OnConfigureServices( services );
10987
}
11088

11189
string GetContentRoot()
@@ -121,6 +99,11 @@ string GetContentRoot()
12199
return contentRoot.FullName;
122100
}
123101

102+
protected virtual void OnConfigurePartManager( ApplicationPartManager partManager ) =>
103+
partManager.ApplicationParts.Add( new TestApplicationPart( FilteredControllerTypes ) );
104+
105+
protected virtual void OnConfigureServices( IServiceCollection services ) { }
106+
124107
protected abstract void OnAddApiVersioning( ApiVersioningOptions options );
125108

126109
protected virtual void OnConfigureRoutes( IRouteBuilder routeBuilder ) { }

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Microsoft.AspNetCore.Mvc.Acceptance.Tests.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
5+
<RootNamespace>Microsoft.AspNetCore</RootNamespace>
56
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
67
<AssetTargetFallback>$(AssetTargetFallback);portable-net451+win8</AssetTargetFallback>
78
<PreserveCompilationContext>true</PreserveCompilationContext>
89
</PropertyGroup>
910

1011
<ItemGroup>
1112
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.csproj" />
13+
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.OData.Versioning\Microsoft.AspNetCore.OData.Versioning.csproj" />
1214
</ItemGroup>
1315

1416
<ItemGroup>
15-
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.4-*" />
17+
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.6" />
1618
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
1719
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" />
1820
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/BasicAcceptanceTest.cs renamed to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Mvc/Basic/BasicAcceptanceTest.cs

File renamed without changes.

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/HelloWorld2Controller.cs renamed to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Mvc/Basic/Controllers/HelloWorld2Controller.cs

File renamed without changes.

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/HelloWorldController.cs renamed to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Mvc/Basic/Controllers/HelloWorldController.cs

File renamed without changes.

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/OverlappingRouteTemplateController.cs renamed to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Mvc/Basic/Controllers/OverlappingRouteTemplateController.cs

File renamed without changes.

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/PingController.cs renamed to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Mvc/Basic/Controllers/PingController.cs

File renamed without changes.

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/Values2Controller.cs renamed to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Mvc/Basic/Controllers/Values2Controller.cs

File renamed without changes.

test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Basic/Controllers/ValuesController.cs renamed to test/Microsoft.AspNetCore.Mvc.Acceptance.Tests/Mvc/Basic/Controllers/ValuesController.cs

File renamed without changes.

0 commit comments

Comments
 (0)