2019-01-02 03:02:39 +03:00
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
2017-10-08 21:44:52 +03:00
|
|
|
|
using Unity;
|
2019-01-02 03:02:39 +03:00
|
|
|
|
using Unity.Interception;
|
2017-10-17 03:02:46 +03:00
|
|
|
|
using Unity.Interception.ContainerIntegration;
|
|
|
|
|
using Unity.Interception.Interceptors;
|
|
|
|
|
using Unity.Interception.Interceptors.TypeInterceptors.VirtualMethodInterception;
|
2013-11-21 17:29:29 +04:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.Practices.Unity.InterceptionExtension.Tests
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Summary description for CodeplexIssuesFixture
|
|
|
|
|
/// </summary>
|
|
|
|
|
[TestClass]
|
|
|
|
|
public class CodeplexIssuesFixture
|
|
|
|
|
{
|
|
|
|
|
public interface IRepository { }
|
|
|
|
|
public class TestRepository : IRepository { }
|
|
|
|
|
public class TestService
|
|
|
|
|
{
|
|
|
|
|
public TestService(IRepository repository)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestMethod]
|
|
|
|
|
public void DependenciesAndInterceptionMixProperly()
|
|
|
|
|
{
|
|
|
|
|
var container = new UnityContainer()
|
|
|
|
|
.AddNewExtension<Interception>()
|
|
|
|
|
.RegisterType<IRepository, TestRepository>()
|
|
|
|
|
.RegisterType<TestService>(
|
2014-04-13 05:38:57 +04:00
|
|
|
|
new Interceptor<VirtualMethodInterceptor>());
|
2013-11-21 17:29:29 +04:00
|
|
|
|
|
|
|
|
|
var svc1 = container.Resolve<TestService>();
|
|
|
|
|
var svc2 = container.Resolve<TestService>();
|
|
|
|
|
|
|
|
|
|
Assert.AreNotSame(svc1, svc2);
|
|
|
|
|
Assert.IsNotNull(svc1 as IInterceptingProxy);
|
|
|
|
|
Assert.IsNotNull(svc2 as IInterceptingProxy);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|