/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

  1. using LinFu.IoC;
  2. using LinFu.Proxy;
  3. using Moq;
  4. using Xunit;
  5. using SampleLibrary;
  6. using SampleLibrary.IOC;
  7. namespace LinFu.UnitTests.Reflection
  8. {
  9. public class DuckTypingTests
  10. {
  11. [Fact]
  12. public void ShouldBeAbleToRedirectInterfaceCallToTarget()
  13. {
  14. var container = new ServiceContainer();
  15. container.LoadFromBaseDirectory("*.dll");
  16. // The duck should call the implementation instance
  17. var mock = new Mock<SampleDuckTypeImplementation>();
  18. mock.Expect(i => i.DoSomething());
  19. object target = mock.Object;
  20. var sampleService = target.CreateDuck<ISampleService>();
  21. sampleService.DoSomething();
  22. mock.VerifyAll();
  23. }
  24. }
  25. }