示例#1
0
        public void GetLoadedTypes()
        {
            // Arrange
            MockType baseType =
                new MockType("BaseType")
                .Property(typeof(int), "ID");

            MockType derivedType =
                new MockType("DerivedType")
                .Property(typeof(int), "DerivedTypeId")
                .BaseType(baseType);

            MockAssembly assembly = new MockAssembly(baseType, derivedType);
            IWebApiAssembliesResolver resolver   = WebApiAssembliesResolverFactory.Create(assembly);
            IEnumerable <Type>        foundTypes = TypeHelper.GetLoadedTypes(resolver);

            IEnumerable <string> definedNames = assembly.GetTypes().Select(t => t.FullName);
            IEnumerable <string> foundNames   = foundTypes.Select(t => t.FullName);

            foreach (string name in definedNames)
            {
                Assert.Contains(name, foundNames);
            }

            Assert.DoesNotContain(typeof(TypeHelperTest), foundTypes);
        }