Skip to content

Commit 6277ecf

Browse files
authored
Infrastructure Update to improve Testability (#881)
* Update Unity to 5.11.7 (cherry picked from commit 1fa54fa) * move all Unit tests to the Unit namespace (cherry picked from commit ea50767) * refactor ConfigurationEntry for testability (cherry picked from commit 4d24d32) * Migration to MSTest V2 (cherry picked from commit 4e2c696) * Consolidate Nuget packages
1 parent 498a8b7 commit 6277ecf

Some content is hidden

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

46 files changed

+447
-375
lines changed

Bonobo.Git.Server.Test/Bonobo.Git.Server.Test.csproj

+39-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" />
34
<Import Project="..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -48,6 +49,9 @@
4849
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
4950
</PropertyGroup>
5051
<ItemGroup>
52+
<Reference Include="Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
53+
<HintPath>..\packages\Castle.Core.4.4.0\lib\net45\Castle.Core.dll</HintPath>
54+
</Reference>
5155
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
5256
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
5357
<Private>True</Private>
@@ -56,6 +60,15 @@
5660
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
5761
<Private>True</Private>
5862
</Reference>
63+
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
64+
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
65+
</Reference>
66+
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
67+
<HintPath>..\packages\MSTest.TestFramework.2.1.2\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
68+
</Reference>
69+
<Reference Include="Moq, Version=4.15.0.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
70+
<HintPath>..\packages\Moq.4.15.2\lib\net45\Moq.dll</HintPath>
71+
</Reference>
5972
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
6073
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
6174
<Private>True</Private>
@@ -90,30 +103,30 @@
90103
<Private>True</Private>
91104
</Reference>
92105
<Reference Include="System.Drawing" />
106+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
107+
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\netstandard1.0\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
108+
</Reference>
109+
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
110+
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll</HintPath>
111+
</Reference>
93112
<Reference Include="System.Web" />
94113
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
95-
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll</HintPath>
96-
<Private>True</Private>
114+
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.Helpers.dll</HintPath>
97115
</Reference>
98-
<Reference Include="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
99-
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll</HintPath>
100-
<Private>True</Private>
116+
<Reference Include="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
117+
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.2.7\lib\net45\System.Web.Mvc.dll</HintPath>
101118
</Reference>
102119
<Reference Include="System.Web.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
103-
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll</HintPath>
104-
<Private>True</Private>
120+
<HintPath>..\packages\Microsoft.AspNet.Razor.3.2.7\lib\net45\System.Web.Razor.dll</HintPath>
105121
</Reference>
106122
<Reference Include="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
107-
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll</HintPath>
108-
<Private>True</Private>
123+
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.dll</HintPath>
109124
</Reference>
110125
<Reference Include="System.Web.WebPages.Deployment, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
111-
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
112-
<Private>True</Private>
126+
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Deployment.dll</HintPath>
113127
</Reference>
114128
<Reference Include="System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
115-
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
116-
<Private>True</Private>
129+
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.2.7\lib\net45\System.Web.WebPages.Razor.dll</HintPath>
117130
</Reference>
118131
<Reference Include="WebDriver, Version=3.3.0.0, Culture=neutral, processorArchitecture=MSIL">
119132
<HintPath>..\packages\Selenium.WebDriver.3.3.0\lib\net40\WebDriver.dll</HintPath>
@@ -130,13 +143,7 @@
130143
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
131144
</ItemGroup>
132145
</When>
133-
<Otherwise>
134-
<ItemGroup>
135-
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework">
136-
<Private>False</Private>
137-
</Reference>
138-
</ItemGroup>
139-
</Otherwise>
146+
<Otherwise />
140147
</Choose>
141148
<ItemGroup>
142149
<Compile Include="MembershipTests\ADTests\ADBackendStoreTest.cs" />
@@ -159,16 +166,17 @@
159166
<Compile Include="MembershipTests\MembershipServiceTestBase.cs" />
160167
<Compile Include="MembershipTests\EFTests\SqliteTestConnection.cs" />
161168
<Compile Include="MembershipTests\EFTests\SqlServerTestConnection.cs" />
162-
<Compile Include="UnitTests\CustomHtmlHelperTest.cs" />
163-
<Compile Include="UnitTests\DatabaseUpdateTestsSqlite.cs" />
164-
<Compile Include="UnitTests\DatabaseUpdateTestsSqlServer.cs" />
165-
<Compile Include="UnitTests\PathEncoderTest.cs" />
169+
<Compile Include="Unit\CustomHtmlHelperTest.cs" />
170+
<Compile Include="Unit\DatabaseUpdateTestsSqlite.cs" />
171+
<Compile Include="Unit\DatabaseUpdateTestsSqlServer.cs" />
172+
<Compile Include="Unit\PathEncoderTest.cs" />
166173
<Compile Include="Properties\AssemblyInfo.cs" />
167174
<Compile Include="TestCategories.cs" />
168-
<Compile Include="UnitTests\PasswordServiceTest.cs" />
169-
<Compile Include="UnitTests\GitAuthorizeAttributeTest.cs" />
170-
<Compile Include="UnitTests\UserExtensionsTests.cs" />
171-
<Compile Include="UnitTests\UserModelTest.cs" />
175+
<Compile Include="Unit\PasswordServiceTest.cs" />
176+
<Compile Include="Unit\GitAuthorizeAttributeTest.cs" />
177+
<Compile Include="Unit\UserConfigurationTests.cs" />
178+
<Compile Include="Unit\UserExtensionsTests.cs" />
179+
<Compile Include="Unit\UserModelTest.cs" />
172180
</ItemGroup>
173181
<ItemGroup>
174182
<ProjectReference Include="..\Bonobo.Git.Server\Bonobo.Git.Server.csproj">
@@ -208,6 +216,8 @@
208216
<Error Condition="!Exists('..\packages\Selenium.WebDriver.IEDriver.3.3.0\build\Selenium.WebDriver.IEDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.IEDriver.3.3.0\build\Selenium.WebDriver.IEDriver.targets'))" />
209217
<Error Condition="!Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.29.0\build\Selenium.WebDriver.ChromeDriver.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Selenium.WebDriver.ChromeDriver.2.29.0\build\Selenium.WebDriver.ChromeDriver.targets'))" />
210218
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
219+
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.props'))" />
220+
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets'))" />
211221
</Target>
212222
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
213223
Other similar extension points exist, see Microsoft.Common.targets. -->
@@ -217,6 +227,7 @@
217227
<Import Project="..\packages\System.Data.SQLite.Core.1.0.104.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.104.0\build\net46\System.Data.SQLite.Core.targets')" />
218228
<Import Project="..\packages\Selenium.WebDriver.IEDriver.3.3.0\build\Selenium.WebDriver.IEDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.IEDriver.3.3.0\build\Selenium.WebDriver.IEDriver.targets')" />
219229
<Import Project="..\packages\Selenium.WebDriver.ChromeDriver.2.29.0\build\Selenium.WebDriver.ChromeDriver.targets" Condition="Exists('..\packages\Selenium.WebDriver.ChromeDriver.2.29.0\build\Selenium.WebDriver.ChromeDriver.targets')" />
230+
<Import Project="..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.2\build\net45\MSTest.TestAdapter.targets')" />
220231
<!-- <Target Name="AfterBuild">
221232
</Target>
222233
-->

Bonobo.Git.Server.Test/UnitTests/CustomHtmlHelperTest.cs Bonobo.Git.Server.Test/Unit/CustomHtmlHelperTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Bonobo.Git.Server.Helpers;
55
using Microsoft.VisualStudio.TestTools.UnitTesting;
66

7-
namespace Bonobo.Git.Server.Test.UnitTests
7+
namespace Bonobo.Git.Server.Test.Unit
88
{
99
[TestClass]
1010
public class CustomHtmlHelperTest

Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlServer.cs Bonobo.Git.Server.Test/Unit/DatabaseUpdateTestsSqlServer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Bonobo.Git.Server.Data.Update;
55
using Bonobo.Git.Server.Data;
66

7-
namespace Bonobo.Git.Server.Test.UnitTests
7+
namespace Bonobo.Git.Server.Test.Unit
88
{
99
[TestClass]
1010
public class DatabaseUpdateTestsSqlServer

Bonobo.Git.Server.Test/UnitTests/DatabaseUpdateTestsSqlite.cs Bonobo.Git.Server.Test/Unit/DatabaseUpdateTestsSqlite.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Bonobo.Git.Server.Data.Update;
55
using Bonobo.Git.Server.Data;
66

7-
namespace Bonobo.Git.Server.Test.UnitTests
7+
namespace Bonobo.Git.Server.Test.Unit
88
{
99
[TestClass]
1010
public class DatabaseUpdateTestsSqlite
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Bonobo.Git.Server.Configuration;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using Moq;
4+
5+
namespace Bonobo.Git.Server.Test.Unit
6+
{
7+
[TestClass]
8+
public class UserConfigurationTests
9+
{
10+
[TestMethod]
11+
public void UserConfiguration_Current_Can_Be_Used_After_Preparing_PathResolver()
12+
{
13+
Mock<IPathResolver> pathResolverMock = new Mock<IPathResolver>();
14+
pathResolverMock.Setup(pr => pr.ResolveWithConfiguration(It.IsAny<string>()))
15+
.Returns("BonoboTestConfig.config");
16+
UserConfiguration.PathResolver = pathResolverMock.Object;
17+
Assert.IsNotNull(UserConfiguration.Current);
18+
}
19+
}
20+
}

Bonobo.Git.Server.Test/UnitTests/UserExtensionsTests.cs Bonobo.Git.Server.Test/Unit/UserExtensionsTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections.Generic;
55
using System.Linq;
66

7-
namespace Bonobo.Git.Server.Test.UnitTests
7+
namespace Bonobo.Git.Server.Test.Unit
88
{
99
[TestClass]
1010
public class UserExtensionsTests

Bonobo.Git.Server.Test/UnitTests/UserModelTest.cs Bonobo.Git.Server.Test/Unit/UserModelTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using Bonobo.Git.Server.Models;
22
using Microsoft.VisualStudio.TestTools.UnitTesting;
33

4-
namespace Bonobo.Git.Server.Test.UnitTests
4+
namespace Bonobo.Git.Server.Test.Unit
55
{
66
[TestClass]
77
public sealed class UserModelTest

Bonobo.Git.Server.Test/app.config

+13-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</dependentAssembly>
3333
<dependentAssembly>
3434
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
35-
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
35+
<bindingRedirect oldVersion="0.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
3636
</dependentAssembly>
3737
<dependentAssembly>
3838
<assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
@@ -54,6 +54,18 @@
5454
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
5555
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
5656
</dependentAssembly>
57+
<dependentAssembly>
58+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
59+
<bindingRedirect oldVersion="0.0.0.0-4.0.4.1" newVersion="4.0.4.1" />
60+
</dependentAssembly>
61+
<dependentAssembly>
62+
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
63+
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
64+
</dependentAssembly>
65+
<dependentAssembly>
66+
<assemblyIdentity name="Unity.Abstractions" publicKeyToken="489b6accfaf20ef0" culture="neutral" />
67+
<bindingRedirect oldVersion="0.0.0.0-5.11.6.0" newVersion="5.11.6.0" />
68+
</dependentAssembly>
5769
</assemblyBinding>
5870
</runtime>
5971
<entityFramework>
+9-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3+
<package id="Castle.Core" version="4.4.0" targetFramework="net46" />
34
<package id="EntityFramework" version="6.1.3" targetFramework="net451" />
4-
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" />
5+
<package id="Microsoft.AspNet.Mvc" version="5.2.7" targetFramework="net46" />
56
<package id="Microsoft.AspNet.Mvc.Futures" version="5.0.0" targetFramework="net451" />
6-
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" />
7-
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" />
7+
<package id="Microsoft.AspNet.Razor" version="3.2.7" targetFramework="net46" />
8+
<package id="Microsoft.AspNet.WebPages" version="3.2.7" targetFramework="net46" />
89
<package id="Microsoft.Net.Compilers" version="2.2.0" targetFramework="net46" developmentDependency="true" />
910
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
11+
<package id="Moq" version="4.15.2" targetFramework="net46" />
12+
<package id="MSTest.TestAdapter" version="2.1.2" targetFramework="net46" />
13+
<package id="MSTest.TestFramework" version="2.1.2" targetFramework="net46" />
1014
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
1115
<package id="Selenium.Support" version="3.3.0" targetFramework="net46" />
1216
<package id="Selenium.WebDriver" version="3.3.0" targetFramework="net46" />
@@ -17,4 +21,6 @@
1721
<package id="System.Data.SQLite.Core" version="1.0.104.0" targetFramework="net46" />
1822
<package id="System.Data.SQLite.EF6" version="1.0.104.0" targetFramework="net46" />
1923
<package id="System.Data.SQLite.Linq" version="1.0.104.0" targetFramework="net46" />
24+
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net46" />
25+
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net46" />
2026
</packages>
+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
using System;
2+
3+
using Unity;
4+
5+
namespace Bonobo.Git.Server
6+
{
7+
/// <summary>
8+
/// Specifies the Unity configuration for the main container.
9+
/// </summary>
10+
public static class UnityConfig
11+
{
12+
#region Unity Container
13+
private static Lazy<IUnityContainer> container =
14+
new Lazy<IUnityContainer>(() =>
15+
{
16+
var container = new UnityContainer();
17+
RegisterTypes(container);
18+
return container;
19+
});
20+
21+
/// <summary>
22+
/// Configured Unity Container.
23+
/// </summary>
24+
public static IUnityContainer Container => container.Value;
25+
#endregion
26+
27+
/// <summary>
28+
/// Registers the type mappings with the Unity container.
29+
/// </summary>
30+
/// <param name="container">The unity container to configure.</param>
31+
/// <remarks>
32+
/// There is no need to register concrete types such as controllers or
33+
/// API controllers (unless you want to change the defaults), as Unity
34+
/// allows resolving a concrete type even if it was not previously
35+
/// registered.
36+
/// </remarks>
37+
public static void RegisterTypes(IUnityContainer container)
38+
{
39+
// NOTE: To load from web.config uncomment the line below.
40+
// Make sure to add a Unity.Configuration to the using statements.
41+
// container.LoadConfiguration();
42+
43+
// TODO: Register your type's mappings here.
44+
// container.RegisterType<IProductRepository, ProductRepository>();
45+
}
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System.Linq;
2+
using System.Web.Mvc;
3+
4+
using Unity.AspNet.Mvc;
5+
6+
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Bonobo.Git.Server.UnityMvcActivator), nameof(Bonobo.Git.Server.UnityMvcActivator.Start))]
7+
[assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(Bonobo.Git.Server.UnityMvcActivator), nameof(Bonobo.Git.Server.UnityMvcActivator.Shutdown))]
8+
9+
namespace Bonobo.Git.Server
10+
{
11+
/// <summary>
12+
/// Provides the bootstrapping for integrating Unity with ASP.NET MVC.
13+
/// </summary>
14+
public static class UnityMvcActivator
15+
{
16+
/// <summary>
17+
/// Integrates Unity when the application starts.
18+
/// </summary>
19+
public static void Start()
20+
{
21+
FilterProviders.Providers.Remove(FilterProviders.Providers.OfType<FilterAttributeFilterProvider>().First());
22+
FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(UnityConfig.Container));
23+
24+
DependencyResolver.SetResolver(new UnityDependencyResolver(UnityConfig.Container));
25+
26+
// TODO: Uncomment if you want to use PerRequestLifetimeManager
27+
// Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule));
28+
}
29+
30+
/// <summary>
31+
/// Disposes the Unity container when the application is shut down.
32+
/// </summary>
33+
public static void Shutdown()
34+
{
35+
UnityConfig.Container.Dispose();
36+
}
37+
}
38+
}

Bonobo.Git.Server/Attributes/AllViewsAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using Bonobo.Git.Server.App_GlobalResources;
22
using Bonobo.Git.Server.Models;
33
using Bonobo.Git.Server.Security;
4-
using Microsoft.Practices.Unity;
54
using System;
65
using System.Collections.Generic;
76
using System.Linq;
87
using System.Web.Mvc;
8+
using Unity;
99

1010
namespace Bonobo.Git.Server.Attributes
1111
{

0 commit comments

Comments
 (0)