public void FluentPropertyAttribute() { var model = new NamedFluentModel(); var type = model.GetType(); var properties = type.GetProperties(); foreach (var property in properties) { var fluentPropertyAttribute = property.GetCustomAttributes(typeof(FluentPropertyAttribute), false).SingleOrDefault() as FluentPropertyAttribute; Assert.IsNotNull(fluentPropertyAttribute); Assert.IsInstanceOfType(fluentPropertyAttribute, typeof(FluentPropertyAttribute)); if (property.Name.Equals("BooleanProperty")) { Assert.AreEqual(fluentPropertyAttribute.Name, NamedFluentModel.BOOLEAN_PROPERTY_NAME); } else if (property.Name.Equals("DateProperty")) { Assert.AreEqual(fluentPropertyAttribute.Name, NamedFluentModel.DATE_PROPERTY_NAME); } else if (property.Name.Equals("DoubleProperty")) { Assert.AreEqual(fluentPropertyAttribute.Name, NamedFluentModel.DOUBLE_PROPERTY_NAME); } else if (property.Name.Equals("IntegerProperty")) { Assert.AreEqual(fluentPropertyAttribute.Name, NamedFluentModel.INTEGER_PROPERTY_NAME); } else if (property.Name.Equals("ObjectProperty")) { Assert.AreEqual(fluentPropertyAttribute.Name, NamedFluentModel.OBJECT_PROPERTY_NAME); } } }
public void ShouldMapToFluentObject_WithAttributeNames() { var fluentModel = new NamedFluentModel(true); var fluentObject = fluentModel.MapToFluentObject(); Assert.IsNotNull(fluentObject); Assert.AreEqual(fluentObject.Name, NamedFluentModel.MODEL_NAME); Assert.IsTrue(fluentObject.ContainsKey(NamedFluentModel.BOOLEAN_PROPERTY_NAME)); Assert.IsTrue(fluentObject.ContainsKey(NamedFluentModel.DATE_PROPERTY_NAME)); Assert.IsTrue(fluentObject.ContainsKey(NamedFluentModel.DOUBLE_PROPERTY_NAME)); Assert.IsTrue(fluentObject.ContainsKey(NamedFluentModel.INTEGER_PROPERTY_NAME)); Assert.IsTrue(fluentObject.ContainsKey(NamedFluentModel.OBJECT_PROPERTY_NAME)); Assert.IsFalse(fluentObject.ContainsKey(NamedFluentModel.READONLY_PROPERTY_NAME)); Assert.IsTrue(fluentObject.ContainsKey(NamedFluentModel.CONDITIONED_PROPERTY_NAME)); Assert.IsFalse(fluentObject.ContainsKey(NamedFluentModel.CONDITIONED_REVERSE_PROPERTY_NAME)); Assert.AreEqual(fluentObject[NamedFluentModel.BOOLEAN_PROPERTY_NAME], NamedFluentModel.BOOLEAN_VALUE.ToString()); Assert.AreEqual(fluentObject[NamedFluentModel.DATE_PROPERTY_NAME], NamedFluentModel.DATE_VALUE.ToString()); Assert.AreEqual(fluentObject[NamedFluentModel.DOUBLE_PROPERTY_NAME], NamedFluentModel.DOUBLE_VALUE.ToString()); Assert.AreEqual(fluentObject[NamedFluentModel.INTEGER_PROPERTY_NAME], NamedFluentModel.INTEGER_VALUE.ToString()); Assert.AreEqual(fluentObject[NamedFluentModel.OBJECT_PROPERTY_NAME], NamedFluentModel.OBJECT_VALUE.ToString()); Assert.AreEqual(fluentObject[NamedFluentModel.CONDITIONED_PROPERTY_NAME], NamedFluentModel.CONDITIONED_VALUE); }
public void FluentEntityAttribute() { var model = new NamedFluentModel(); var type = model.GetType(); var fluentEntityAttribute = type.GetCustomAttributes(typeof(FluentEntityAttribute), false).SingleOrDefault() as FluentEntityAttribute; Assert.IsNotNull(fluentEntityAttribute); Assert.IsInstanceOfType(fluentEntityAttribute, typeof(FluentEntityAttribute)); Assert.AreEqual(fluentEntityAttribute.Name, NamedFluentModel.MODEL_NAME); }