public void Test_GetMappedReverseRelationshipName_WhenNoAttribute_ShouldReturnNull() { //---------------Set up test pack------------------- PropertyInfo info = RandomValueGenerator.GetMockPropInfoWithNoAutoMapProp <AutoMapOneToManyAttribute>(); PropertyWrapper propertyWrapper = info.ToPropertyWrapper(); object[] customAttributes = info.GetCustomAttributes(typeof(AutoMapOneToManyAttribute), true); //---------------Assert Precondition---------------- Assert.IsNotNull(customAttributes); Assert.AreEqual(0, customAttributes.Count()); //---------------Execute Test ---------------------- string mappedReverseRelationshipName = propertyWrapper.GetMappedReverseRelationshipName <AutoMapOneToManyAttribute>(); //---------------Test Result ----------------------- Assert.IsNull(mappedReverseRelationshipName); }
public void Test_GetMappedReverseRelationshipName_WhenAutoMapPropWithReverseRel_ShouldReturnReverseRel() { //---------------Set up test pack------------------- const string expectedRevRelName = "MappedRevRel"; PropertyInfo info = RandomValueGenerator.GetMockPropInfoWithAutoMapAttribute <AutoMapOneToManyAttribute>(expectedRevRelName); PropertyWrapper propertyWrapper = info.ToPropertyWrapper(); object[] customAttributes = info.GetCustomAttributes(typeof(AutoMapOneToManyAttribute), true); //---------------Assert Precondition---------------- Assert.IsNotNull(customAttributes); Assert.AreEqual(1, customAttributes.Count()); var autoMapRelationshipAttribute = customAttributes[0] as AutoMapRelationshipAttribute; Assert.IsNotNull(autoMapRelationshipAttribute); Assert.IsNotNullOrEmpty(autoMapRelationshipAttribute.ReverseRelationshipName); //---------------Execute Test ---------------------- string mappedReverseRelationshipName = propertyWrapper.GetMappedReverseRelationshipName <AutoMapOneToManyAttribute>(); //---------------Test Result ----------------------- Assert.AreEqual(expectedRevRelName, mappedReverseRelationshipName); }