/src/UnitTests/Finders/MethodFinderTests.cs

http://github.com/philiplaureano/LinFu · C# · 29 lines · 26 code · 3 blank · 0 comment · 1 complexity · 53e4436419c30caa7ed429f1b3ea5ef6 MD5 · raw file

  1. using System.Linq;
  2. using System.Reflection;
  3. using LinFu.IoC;
  4. using LinFu.IoC.Configuration;
  5. using LinFu.IoC.Configuration.Interfaces;
  6. using Xunit;
  7. using SampleLibrary.IOC;
  8. namespace LinFu.UnitTests.Finders
  9. {
  10. public class MethodFinderTests
  11. {
  12. [Fact]
  13. public void ShouldFindGenericMethod()
  14. {
  15. var container = new ServiceContainer();
  16. container.LoadFromBaseDirectory("*.dll");
  17. var context = new MethodFinderContext(new[] {typeof(object)}, new object[0], typeof(void));
  18. var methods =
  19. typeof(SampleClassWithGenericMethod).GetMethods(BindingFlags.Public | BindingFlags.Instance);
  20. var finder = container.GetService<IMethodFinder<MethodInfo>>();
  21. var result = finder.GetBestMatch(methods, context);
  22. Assert.True(result.IsGenericMethod);
  23. Assert.True(result.GetGenericArguments().Count() == 1);
  24. }
  25. }
  26. }