Esempio n. 1
0
        public void TestPropertyByPartialName()
        {
            Flags flags = Flags.InstanceAnyVisibility | Flags.PartialNameMatch;

            var expectedName = AnimalInstancePropertyNames.Where(s => s.Contains("C")).First();
            var property     = typeof(Animal).Property("C", flags);

            Assert.IsNotNull(property);
            Assert.AreEqual(expectedName, property.Name);

            expectedName = AnimalInstancePropertyNames.Where(s => s.Contains("B")).First();
            property     = typeof(Animal).Property("B", flags);
            Assert.IsNotNull(property);
            Assert.AreEqual(expectedName, property.Name);
        }
Esempio n. 2
0
        public void TestPropertyByPartialName()
        {
            FasterflectFlags flags = FasterflectFlags.InstanceAnyVisibility | FasterflectFlags.PartialNameMatch;

            List <string> expectedNames = AnimalInstancePropertyNames.Where(s => s.Contains("C")).ToList();
            PropertyInfo  property      = typeof(Animal).Property("C", flags);

            Assert.IsNotNull(property);
            string name = expectedNames.FirstOrDefault(n => property.Name == n);

            //Assert.AreEqual(name, property.Name);

            expectedNames = AnimalInstancePropertyNames.Where(s => s.Contains("B")).ToList();
            property      = typeof(Animal).Property("B", flags);
            Assert.IsNotNull(property);
            name = expectedNames.FirstOrDefault(n => property.Name == n);
            //Assert.AreEqual(name, property.Name);
        }
Esempio n. 3
0
        public void TestPropertiesWithNameFilterList()
        {
            IList <PropertyInfo> properties = typeof(object).Properties(AnimalInstancePropertyNames);

            Assert.AreEqual(0, properties.Count);

            properties = typeof(Animal).Properties(AnimalInstancePropertyNames);
            CollectionAssert.AreEquivalent(AnimalInstancePropertyNames, properties.Select(p => p.Name).ToArray());

            properties = typeof(Lion).Properties(AnimalInstancePropertyNames);
            CollectionAssert.AreEquivalent(AnimalInstancePropertyNames, properties.Select(p => p.Name).ToArray());
            CollectionAssert.AreEquivalent(AnimalInstancePropertyTypes, properties.Select(p => p.PropertyType).ToArray());

            string[] list = AnimalInstancePropertyNames.Where(s => s.Contains("C")).ToArray();
            properties = typeof(Animal).Properties(list);
            CollectionAssert.AreEquivalent(list, properties.Select(p => p.Name).ToArray());

            list       = AnimalInstancePropertyNames.Where(s => s.Contains("B")).ToArray();
            properties = typeof(Lion).Properties(list);
            CollectionAssert.AreEquivalent(list, properties.Select(p => p.Name).ToArray());
        }