PageRenderTime 122ms CodeModel.GetById 61ms app.highlight 2ms RepoModel.GetById 58ms app.codeStats 0ms

/src/UnitTests/Reflection/DuckTypingTests.cs

http://github.com/philiplaureano/LinFu
C# | 30 lines | 24 code | 5 blank | 1 comment | 0 complexity | 0ffa8519acf642cfea8170490b7ba5d4 MD5 | raw file
 1using LinFu.IoC;
 2using LinFu.Proxy;
 3using Moq;
 4using Xunit;
 5using SampleLibrary;
 6using SampleLibrary.IOC;
 7
 8namespace LinFu.UnitTests.Reflection
 9{
10    public class DuckTypingTests
11    {
12        [Fact]
13        public void ShouldBeAbleToRedirectInterfaceCallToTarget()
14        {
15            var container = new ServiceContainer();
16            container.LoadFromBaseDirectory("*.dll");
17
18            // The duck should call the implementation instance
19            var mock = new Mock<SampleDuckTypeImplementation>();
20            mock.Expect(i => i.DoSomething());
21
22            object target = mock.Object;
23
24            var sampleService = target.CreateDuck<ISampleService>();
25            sampleService.DoSomething();
26
27            mock.VerifyAll();
28        }
29    }
30}