public void GetResult_WhenCalledAfterInstantiationAndPropertyDoesNotHaveAtrribute_ReturnsEmptyMaybe() { // ARRANGE Type testType = typeof(TestObject); PropertyInfo property = testType.GetProperty("Name1"); // ACT Maybe<NameAttribute> actual = new PropertyNameAttributeFinder(property).GetResult(); // ASSERT Assert.IsNull(actual.FirstOrDefault()); }
public void HasAttribute_WhenCalledAfterInstantiationAndPropertyDoesHaveAtrribute_ReturnsTrue() { // ARRANGE Type testType = typeof(TestObject); PropertyInfo property = testType.GetProperty("Name2"); // ACT bool actual = new PropertyNameAttributeFinder(property) .HasFoundAttribute; // ASSERT Assert.IsTrue(actual); }
public void GetResult_WhenCalledAfterInstantiationAndPropertyDoesHaveAtrribute_ReturnsMaybePopulatedWithInstanceOfAttribute() { // ARRANGE Type testType = typeof(TestObject); PropertyInfo property = testType.GetProperty("Name2"); // ACT Maybe<NameAttribute> actual = new PropertyNameAttributeFinder(property).GetResult(); // ASSERT Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual.FirstOrDefault(), typeof(NameAttribute)); }
private void SetCurrentFieldNameFromCurrentPropertyAttributeOrPropertyName() { Maybe<NameAttribute> nameAttribute = new PropertyNameAttributeFinder(CurrentProperty).GetResult(); CurrentFieldName = nameAttribute.HasItem ? nameAttribute.Single().Value : CurrentProperty.Name; }