/src/Ninject.Extensions.Interception.Test/PropertyInterceptionContextDynamicProxy2.cs
C# | 49 lines | 40 code | 9 blank | 0 comment | 0 complexity | cfc1106a02d722910aa1b7982f6bc7ec MD5 | raw file
Possible License(s): Apache-2.0, LGPL-3.0, MPL-2.0-no-copyleft-exception
- namespace Ninject.Extensions.Interception
- {
- using FluentAssertions;
- using Ninject.Extensions.Interception.Fakes;
- using Ninject.Extensions.Interception.Infrastructure.Language;
- using Xunit;
-
- public class PropertyInterceptionContextDynamicProxy2 : PropertyInterceptionContext<DynamicProxyModule>
- {
- [Fact]
- public void PropertySetInterceptedBefore()
- {
- using (var kernel = CreateDefaultInterceptionKernel())
- {
- kernel.InterceptBeforeSet<Mock>(
- o => o.MyProperty,
- i => i.Request.Arguments[0] = "intercepted");
- var obj = kernel.Get<Mock>();
- obj.Should().NotBeNull();
- obj.MyProperty = "end";
- obj.MyProperty.Should().Be("intercepted");
- }
- }
- [Fact]
- public void PropertySetInterceptedAfter()
- {
- string testString = "empty";
- using (var kernel = CreateDefaultInterceptionKernel())
- {
- kernel.InterceptAfterSet<Mock>(
- o => o.MyProperty,
- i => testString = ((Mock)i.Request.Target).MyProperty);
- var obj = kernel.Get<Mock>();
- obj.MyProperty.Should().Be("start");
- obj.MyProperty = "end";
- obj.MyProperty.Should().Be("end");
- testString.Should().Be("end");
- }
- }
- }
- }