public void Test_ReadOnly_IsEditable_False() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("Name", "NN", "String", PropReadWriteRule.ReadOnly, "DD", "", false, false); BOProp prop1 = new BOProp(propDef); //---------------Assert Precondition---------------- Assert.AreEqual(PropReadWriteRule.ReadOnly, prop1.PropDef.ReadWriteRule); //---------------Execute Test ---------------------- string message; bool isEditable = prop1.IsEditable(out message); //---------------Test Result ----------------------- Assert.IsFalse(isEditable); StringAssert.Contains("The property ", message); StringAssert.Contains("Name' is not editable since it is set up as ReadOnly", message); }
public void Test_WriteNew_NewObject_IsEditable_True() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("Name", "NN", "String", PropReadWriteRule.WriteNew, "DD", "", false, false); BOProp prop1 = new BOProp(propDef); prop1.IsObjectNew = true; //---------------Assert Precondition---------------- Assert.AreEqual(PropReadWriteRule.WriteNew, prop1.PropDef.ReadWriteRule); Assert.IsTrue(prop1.IsObjectNew); //---------------Execute Test ---------------------- string message; bool isEditable = prop1.IsEditable(out message); //---------------Test Result ----------------------- Assert.IsTrue(isEditable); Assert.AreEqual("", message); }
public void Test_WriteOnce_PersistedValueSet_IsEditable_False() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("Name", typeof (string), PropReadWriteRule.WriteOnce, "DD", "", false, false); BOProp prop1 = new BOProp(propDef) {Value = "new Value", IsObjectNew = false}; prop1.BackupPropValue(); //---------------Assert Precondition---------------- Assert.AreEqual(PropReadWriteRule.WriteOnce, prop1.PropDef.ReadWriteRule); Assert.IsNotNull(prop1.PersistedPropertyValue); //---------------Execute Test ---------------------- string message; bool isEditable = prop1.IsEditable(out message); //---------------Test Result ----------------------- Assert.IsFalse(isEditable); StringAssert.Contains("The property ", message); StringAssert.Contains ("Name' is not editable since it is set up as WriteOnce and the value has already been set", message); }
public void Test_WriteOnce_NewObject_IsEditable_True() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("Name", typeof (string), PropReadWriteRule.WriteOnce, "DD", "", false, false); BOProp prop1 = new BOProp(propDef) {Value = "new Value"}; prop1.BackupPropValue(); prop1.IsObjectNew = true; //---------------Assert Precondition---------------- Assert.AreEqual(PropReadWriteRule.WriteOnce, prop1.PropDef.ReadWriteRule); Assert.IsNotNull(prop1.PersistedPropertyValue); //---------------Execute Test ---------------------- string message; bool isEditable = prop1.IsEditable(out message); //---------------Test Result ----------------------- Assert.IsTrue(isEditable); Assert.AreEqual("", message); }
public void Test_WriteNotNew_NewObject_IsEditable_False() { //---------------Set up test pack------------------- PropDef propDef = new PropDef("Name", "NN", "String", PropReadWriteRule.WriteNotNew, "DD", "", false, false); BOProp prop1 = new BOProp(propDef); prop1.IsObjectNew = true; //---------------Assert Precondition---------------- Assert.AreEqual(PropReadWriteRule.WriteNotNew, prop1.PropDef.ReadWriteRule); Assert.IsTrue(prop1.IsObjectNew); //---------------Execute Test ---------------------- string message; bool isEditable = prop1.IsEditable(out message); //---------------Test Result ----------------------- Assert.IsFalse(isEditable); StringAssert.Contains("The property ", message); StringAssert.Contains ("Name' is not editable since it is set up as WriteNotNew and the object is new", message); }