BackupPropValue() публичный Метод

Copies the current property value to PersistedValue. This is usually called when the object is persisted to the database.
public BackupPropValue ( ) : void
Результат void
        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_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);
        }
Пример #3
0
        public void Test_PersistedPropertyValueString_ValidDateTime()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);
            DateTime expectedDateTime = DateTime.MinValue.AddDays(1);
            boProp.Value = expectedDateTime;
            boProp.BackupPropValue();
            boProp.Value = "new value";

            //---------------Assert Precondition----------------
            Assert.IsNotNull(boProp.Value);
            Assert.IsNotNull(boProp.PersistedPropertyValue);
            //---------------Execute Test ----------------------
            string persistedPropertyValueString = boProp.PersistedPropertyValueString;

            //---------------Test Result -----------------------
            Assert.IsTrue(boProp.Value is string, "Value should be a expectedString");
            Assert.AreEqual(expectedDateTime.ToString(_standardDateTimeFormat), persistedPropertyValueString);
        }
Пример #4
0
        public void Test_PersistedPropertyValueString_ValidInt()
        {
            //---------------Set up test pack-------------------
            BOProp boProp = new BOProp(_propDef);
            int expectedInt = BOTestUtils.RandomInt;
            boProp.Value = expectedInt;
            boProp.BackupPropValue();
            boProp.Value = "new value";

            //---------------Assert Precondition----------------
            Assert.IsNotNull(boProp.Value);
            Assert.IsNotNull(boProp.PersistedPropertyValue);
            //---------------Execute Test ----------------------
            string persistedPropertyValueString = boProp.PersistedPropertyValueString;
            //---------------Test Result -----------------------
            Assert.IsTrue(boProp.Value is string, "Value should be a expectedString");
            Assert.AreEqual(expectedInt.ToString(), persistedPropertyValueString);
        }
Пример #5
0
 public void Test_PersistedPropertyValueString_ValidGuid()
 {
     //---------------Set up test pack-------------------
     BOProp boProp = new BOProp(_propDef);
     Guid expectedGuid = Guid.NewGuid();
     boProp.Value = expectedGuid;
     boProp.BackupPropValue();
     boProp.Value = "new value";
     //---------------Assert Precondition----------------
     Assert.IsNotNull(boProp.Value);
     Assert.IsNotNull(boProp.PersistedPropertyValue);
     //---------------Execute Test ----------------------
     //---------------Test Result -----------------------
     string persistedPropertyValueString = boProp.PersistedPropertyValueString;
     //---------------Test Result -----------------------
     Assert.AreEqual(expectedGuid.ToString("B").ToUpperInvariant(), persistedPropertyValueString);
 }