Esempio n. 1
0
        public void When_selecting_types_that_derive_from_a_specific_generic_class_it_should_return_the_correct_types()
        {
            // Arrange
            Assembly assembly = typeof(ClassDerivedFromSomeGenericBaseClass).GetTypeInfo().Assembly;

            // Act
            TypeSelector types = AllTypes.From(assembly).ThatDeriveFrom <SomeGenericBaseClass <int> >();

            // Assert
            types.ToArray().Should().ContainSingle()
            .Which.Should().Be(typeof(ClassDerivedFromSomeGenericBaseClass));
        }
Esempio n. 2
0
        public void When_selecting_types_that_do_not_derive_from_a_specific_generic_class_it_should_return_the_correct_types()
        {
            // Arrange
            Assembly assembly = typeof(ClassDerivedFromSomeGenericBaseClass).GetTypeInfo().Assembly;

            // Act
            TypeSelector types = AllTypes.From(assembly)
                                 .ThatAreInNamespace("Internal.Main.Test")
                                 .ThatDoNotDeriveFrom <SomeGenericBaseClass <int> >();

            // Assert
            types.ToArray().Should()
            .HaveCount(12);
        }
Esempio n. 3
0
        public void When_using_the_single_type_ctor_of_TypeSelector_it_should_contain_that_singe_type()
        {
            // Arrange
            Type type = typeof(ClassWithSomeAttribute);

            // Act
            var typeSelector = new TypeSelector(type);

            // Assert
            typeSelector
            .ToArray()
            .Should()
            .ContainSingle()
            .Which.Should().Be(type);
        }
Esempio n. 4
0
        public void When_selecting_types_that_derive_from_a_specific_generic_class_it_should_return_the_correct_types()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------

            Assembly assembly = typeof(ClassDerivedFromSomeGenericBaseClass).GetTypeInfo().Assembly;

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            TypeSelector types = AllTypes.From(assembly).ThatDeriveFrom <SomeGenericBaseClass <int> >();

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            types.ToArray().Should()
            .HaveCount(1)
            .And.Contain(typeof(ClassDerivedFromSomeGenericBaseClass));
        }
Esempio n. 5
0
 /// <summary>
 /// Returns a <see cref="TypeAssertions"/> object that can be used to assert the
 /// current <see cref="System.Type"/>.
 /// </summary>
 public static TypeSelectorAssertions Should(this TypeSelector typeSelector)
 {
     return(new TypeSelectorAssertions(typeSelector.ToArray()));
 }