PageRenderTime 223ms CodeModel.GetById 91ms app.highlight 7ms RepoModel.GetById 123ms app.codeStats 1ms

/src/UnitTests/Reflection/LateBindingTests.cs

http://github.com/philiplaureano/LinFu
C# | 72 lines | 56 code | 16 blank | 0 comment | 0 complexity | 0fba7b2993afd649792b57d1f3ade94f MD5 | raw file
 1using LinFu.IoC.Reflection;
 2using Moq;
 3using Xunit;
 4    
 5using SampleLibrary;
 6using SampleLibrary.IOC;
 7
 8namespace LinFu.UnitTests.Reflection
 9{
10    public class LateBindingTests
11    {
12        [Fact]
13        public void ShouldCallLateBoundGenericMethodWithFourGenericArguments()
14        {
15            var mock = new Mock<ISampleServiceWithGenericMethods>();
16            mock.Expect(m => m.SomeMethod<object, object, object, object>());
17
18            var targetInstance = mock.Object;
19            targetInstance.Invoke<object, object, object, object>("SomeMethod");
20
21            mock.VerifyAll();
22        }
23
24        [Fact]
25        public void ShouldCallLateBoundGenericMethodWithThreeGenericArguments()
26        {
27            var mock = new Mock<ISampleServiceWithGenericMethods>();
28            mock.Expect(m => m.SomeMethod<object, object, object>());
29
30            var targetInstance = mock.Object;
31            targetInstance.Invoke<object, object, object>("SomeMethod");
32
33            mock.VerifyAll();
34        }
35
36        [Fact]
37        public void ShouldCallLateBoundGenericMethodWithTwoGenericArguments()
38        {
39            var mock = new Mock<ISampleServiceWithGenericMethods>();
40            mock.Expect(m => m.SomeMethod<object, object>());
41
42            var targetInstance = mock.Object;
43            targetInstance.Invoke<object, object>("SomeMethod");
44
45            mock.VerifyAll();
46        }
47
48        [Fact]
49        public void ShouldCallLateBoundMethod()
50        {
51            var mock = new Mock<ISampleService>();
52            mock.Expect(m => m.DoSomething());
53
54            var targetInstance = mock.Object;
55            targetInstance.Invoke("DoSomething");
56
57            mock.VerifyAll();
58        }
59
60        [Fact]
61        public void ShouldCallLateBoundMethodWithGenericMethod()
62        {
63            var mock = new Mock<ISampleServiceWithGenericMethods>();
64            mock.Expect(m => m.SomeMethod<object>());
65
66            var targetInstance = mock.Object;
67            targetInstance.Invoke<object>("SomeMethod");
68
69            mock.VerifyAll();
70        }
71    }
72}