-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
498a8b7
commit 6277ecf
Showing
46 changed files
with
447 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Bonobo.Git.Server.Configuration; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Moq; | ||
|
||
namespace Bonobo.Git.Server.Test.Unit | ||
{ | ||
[TestClass] | ||
public class UserConfigurationTests | ||
{ | ||
[TestMethod] | ||
public void UserConfiguration_Current_Can_Be_Used_After_Preparing_PathResolver() | ||
{ | ||
Mock<IPathResolver> pathResolverMock = new Mock<IPathResolver>(); | ||
pathResolverMock.Setup(pr => pr.ResolveWithConfiguration(It.IsAny<string>())) | ||
.Returns("BonoboTestConfig.config"); | ||
UserConfiguration.PathResolver = pathResolverMock.Object; | ||
Assert.IsNotNull(UserConfiguration.Current); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...it.Server.Test/UnitTests/UserModelTest.cs → Bonobo.Git.Server.Test/Unit/UserModelTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
|
||
using Unity; | ||
|
||
namespace Bonobo.Git.Server | ||
{ | ||
/// <summary> | ||
/// Specifies the Unity configuration for the main container. | ||
/// </summary> | ||
public static class UnityConfig | ||
{ | ||
#region Unity Container | ||
private static Lazy<IUnityContainer> container = | ||
new Lazy<IUnityContainer>(() => | ||
{ | ||
var container = new UnityContainer(); | ||
RegisterTypes(container); | ||
return container; | ||
}); | ||
|
||
/// <summary> | ||
/// Configured Unity Container. | ||
/// </summary> | ||
public static IUnityContainer Container => container.Value; | ||
#endregion | ||
|
||
/// <summary> | ||
/// Registers the type mappings with the Unity container. | ||
/// </summary> | ||
/// <param name="container">The unity container to configure.</param> | ||
/// <remarks> | ||
/// There is no need to register concrete types such as controllers or | ||
/// API controllers (unless you want to change the defaults), as Unity | ||
/// allows resolving a concrete type even if it was not previously | ||
/// registered. | ||
/// </remarks> | ||
public static void RegisterTypes(IUnityContainer container) | ||
{ | ||
// NOTE: To load from web.config uncomment the line below. | ||
// Make sure to add a Unity.Configuration to the using statements. | ||
// container.LoadConfiguration(); | ||
|
||
// TODO: Register your type's mappings here. | ||
// container.RegisterType<IProductRepository, ProductRepository>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Linq; | ||
using System.Web.Mvc; | ||
|
||
using Unity.AspNet.Mvc; | ||
|
||
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Bonobo.Git.Server.UnityMvcActivator), nameof(Bonobo.Git.Server.UnityMvcActivator.Start))] | ||
[assembly: WebActivatorEx.ApplicationShutdownMethod(typeof(Bonobo.Git.Server.UnityMvcActivator), nameof(Bonobo.Git.Server.UnityMvcActivator.Shutdown))] | ||
|
||
namespace Bonobo.Git.Server | ||
{ | ||
/// <summary> | ||
/// Provides the bootstrapping for integrating Unity with ASP.NET MVC. | ||
/// </summary> | ||
public static class UnityMvcActivator | ||
{ | ||
/// <summary> | ||
/// Integrates Unity when the application starts. | ||
/// </summary> | ||
public static void Start() | ||
{ | ||
FilterProviders.Providers.Remove(FilterProviders.Providers.OfType<FilterAttributeFilterProvider>().First()); | ||
FilterProviders.Providers.Add(new UnityFilterAttributeFilterProvider(UnityConfig.Container)); | ||
|
||
DependencyResolver.SetResolver(new UnityDependencyResolver(UnityConfig.Container)); | ||
|
||
// TODO: Uncomment if you want to use PerRequestLifetimeManager | ||
// Microsoft.Web.Infrastructure.DynamicModuleHelper.DynamicModuleUtility.RegisterModule(typeof(UnityPerRequestHttpModule)); | ||
} | ||
|
||
/// <summary> | ||
/// Disposes the Unity container when the application is shut down. | ||
/// </summary> | ||
public static void Shutdown() | ||
{ | ||
UnityConfig.Container.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.