Пример #1
0
        public void Commit()
        {
            PropertyValue propertyValue = CreateIntPropertyValue("testProperty", 0);

            propertyValue.Value = 5;
            Assert.That(propertyValue.OriginalValue, Is.EqualTo(0));
            Assert.That(propertyValue.Value, Is.EqualTo(5));
            Assert.That(propertyValue.HasChanged, Is.True);
            Assert.That(propertyValue.HasBeenTouched, Is.True);

            propertyValue.CommitState();

            Assert.That(propertyValue.OriginalValue, Is.EqualTo(5));
            Assert.That(propertyValue.Value, Is.EqualTo(5));
            Assert.That(propertyValue.HasChanged, Is.False);
            Assert.That(propertyValue.HasBeenTouched, Is.False);
        }
Пример #2
0
        public void BinaryDataBug()
        {
            PropertyDefinition definition = PropertyDefinitionObjectMother.CreateForFakePropertyInfo("testProperty2", typeof(byte[]), true);
            var propertyValue             = new PropertyValue(definition, new byte[] { 1, 2, 3 });

            ((byte[])propertyValue.Value)[0] = 7;
            Assert.That(propertyValue.HasChanged, Is.True);
            Assert.That(((byte[])propertyValue.Value)[0], Is.EqualTo(7));
            Assert.That(((byte[])propertyValue.OriginalValue)[0], Is.EqualTo(1));

            propertyValue.RollbackState();
            Assert.That(propertyValue.HasChanged, Is.False);
            Assert.That(((byte[])propertyValue.Value)[0], Is.EqualTo(1));

            ((byte[])propertyValue.Value)[0] = 7;
            Assert.That(propertyValue.HasChanged, Is.True);
            Assert.That(((byte[])propertyValue.Value)[0], Is.EqualTo(7));

            propertyValue.CommitState();
            Assert.That(propertyValue.HasChanged, Is.False);
            Assert.That(((byte[])propertyValue.Value)[0], Is.EqualTo(7));
        }