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); }
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); }
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()); }