コード例 #1
0
ファイル: ChangeSetTests.cs プロジェクト: chrisblock/Changes
        public void ApplyChanges_EnumPropertyOnTypeChanged_PropertyInChangeSetIsChanged()
        {
            const TestEnum testEnumValue = TestEnum.ValueOne;
            const int testIntegerValue = 42;
            const string testStringValue = "The quick brown fox jumped over the lazy dog.";
            var testIntegerEnumeration = new[] { 1, 2, 3, 4, 5 };

            const TestEnum changedEnumValue = TestEnum.ValueTwo;

            var testObject = new TestObject
            {
                TestEnum = testEnumValue,
                TestInteger = testIntegerValue,
                TestString = testStringValue,
                TestIntegerEnumeration = testIntegerEnumeration
            };

            dynamic changeSet = new ChangeSet<TestObject>();

            changeSet.TestEnum = changedEnumValue;

            changeSet.ApplyChanges(ref testObject);

            Assert.That(testObject, Is.Not.Null);
            Assert.That(testObject.TestEnum, Is.EqualTo(changedEnumValue));
            Assert.That(testObject.TestInteger, Is.EqualTo(testIntegerValue));
            Assert.That(testObject.TestString, Is.EqualTo(testStringValue));
        }
コード例 #2
0
ファイル: ChangeSetTests.cs プロジェクト: chrisblock/Changes
        public void ApplyChanges_ChildrenOnTypeChanged_PropertyInChangeSetIsChanged()
        {
            const TestEnum testEnumValue = TestEnum.ValueOne;
            const int testIntegerValue = 42;
            const string testStringValue = "The quick brown fox jumped over the lazy dog.";

            var testChildren = new[]
            {
                new TestObject()
            };

            var testObject = new TestObject
            {
                TestEnum = testEnumValue,
                TestInteger = testIntegerValue,
                TestString = testStringValue,
                Children = new TestObject[0]
            };

            dynamic changeSet = new ChangeSet<TestObject>();

            changeSet.Children = testChildren;

            changeSet.ApplyChanges(ref testObject);

            Assert.That(testObject, Is.Not.Null);
            Assert.That(testObject.TestEnum, Is.EqualTo(testEnumValue));
            Assert.That(testObject.TestInteger, Is.EqualTo(testIntegerValue));
            Assert.That(testObject.TestString, Is.EqualTo(testStringValue));
            Assert.That(testObject.Children, Is.EquivalentTo(testChildren));
        }