/src/UnitTests/Proxy/InterfaceExtractorTests.cs

http://github.com/philiplaureano/LinFu · C# · 32 lines · 26 code · 5 blank · 1 comment · 1 complexity · 045fc2832d76ebb4723a487fed311a07 MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using LinFu.Proxy;
  5. using Xunit;
  6. using SampleLibrary;
  7. namespace LinFu.UnitTests.Proxy
  8. {
  9. public class InterfaceExtractorTests
  10. {
  11. [Fact]
  12. public void InterfaceExtractorShouldReturnTheCorrectResults()
  13. {
  14. var baseType = typeof(SampleClass);
  15. var extractor = new InterfaceExtractor();
  16. var interfaces = new HashSet<Type>();
  17. extractor.GetInterfaces(baseType, interfaces);
  18. Assert.Contains(typeof(ISampleService), interfaces);
  19. Assert.Contains(typeof(ISampleGenericService<int>), interfaces);
  20. // The result list must only contain interface types
  21. var nonInterfaceTypes = from t in interfaces
  22. where !t.IsInterface
  23. select t;
  24. Assert.True(nonInterfaceTypes.Count() == 0);
  25. }
  26. }
  27. }