PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Ninject.Extensions.Interception.Test/DynamicProxy2ChannelFactoryProxyTest.cs

https://github.com/hereyes/ninject.extensions.interception
C# | 37 lines | 31 code | 6 blank | 0 comment | 0 complexity | fcf99b6b537c8964fc5aa7d903782b93 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0, MPL-2.0-no-copyleft-exception
  1. namespace Ninject.Extensions.Interception
  2. {
  3. #if !SILVERLIGHT
  4. using System.ServiceModel;
  5. #endif
  6. using Castle.DynamicProxy;
  7. using FluentAssertions;
  8. using Ninject.Extensions.Interception.Fakes;
  9. using Ninject.Extensions.Interception.Infrastructure.Language;
  10. using Ninject.Extensions.Interception.Interceptors;
  11. using Xunit;
  12. public class DynamicProxy2ChannelFactoryProxyTest : DynamicProxy2BaseTests
  13. {
  14. #if !SILVERLIGHT
  15. [Fact]
  16. public void ProxiesCreatedWithChannelFactoryAreIntercepted()
  17. {
  18. using (StandardKernel kernel = CreateDefaultInterceptionKernel())
  19. {
  20. kernel.Bind<IFooService>().ToMethod(
  21. context =>
  22. ChannelFactory<IFooService>.CreateChannel(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost/FooService")));
  23. kernel.Intercept((request) => true).With<FlagInterceptor>();
  24. var obj = kernel.Get<IFooService>();
  25. obj.Should().NotBeNull();
  26. typeof(IProxyTargetAccessor).IsAssignableFrom(obj.GetType()).Should().BeTrue();
  27. }
  28. }
  29. #endif
  30. }
  31. }