예제 #1
0
        public void Discovers_types_directly_or_implicitly()
        {
            var assemblies = new List<Assembly> {GetType().Assembly};
            var assemblySource = new Mock<IAssemblySource>();
            assemblySource.SetupGet(source => source.Assemblies).Returns(assemblies);

            var typeSource = new TypeSource(assemblySource.Object);

            var results = typeSource
                .Implementing<ITestTypeDiscoveryInterface>()
                .ToList();

            Assert.AreEqual(2, results.Count);
            Assert.IsTrue(typeof(ITestTypeDiscoveryInterface).IsAssignableFrom(results.First()));
            Assert.IsTrue(typeof(ITestTypeDiscoveryInterface).IsAssignableFrom(results.Last()));
        }
예제 #2
0
        public void Can_pass_desired_type_instead_of_using_generics()
        {
            var assemblies = new List<Assembly> { GetType().Assembly };
            var assemblySource = new Mock<IAssemblySource>();
            assemblySource.SetupGet(source => source.Assemblies).Returns(assemblies);

            var typeSource = new TypeSource(assemblySource.Object);

            var results = typeSource
                .Implementing(typeof(ITestTypeDiscoveryInterface))
                .ToList();

            Assert.AreEqual(2, results.Count);
            Assert.IsTrue(typeof(ITestTypeDiscoveryInterface).IsAssignableFrom(results.First()));
            Assert.IsTrue(typeof(ITestTypeDiscoveryInterface).IsAssignableFrom(results.Last()));
        }