comparison HowTo/EditableObjects/AcceptRejectChanges.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using NUnit.Framework;
3 using BLToolkit.EditableObjects;
4
5 namespace HowTo.EditableObjects
6 {
7 [TestFixture]
8 public class AcceptRejectChanges
9 {
10 public /*[a]*/abstract/*[/a]*/ class TestObject : /*[a]*/EditableObject/*[/a]*/<TestObject>
11 {
12 public /*[a]*/abstract/*[/a]*/ string FirstName { get; set; }
13 public /*[a]*/abstract/*[/a]*/ string LastName { get; set; }
14 }
15
16 [Test]
17 public void Test()
18 {
19 // Create an instance.
20 //
21 TestObject obj = TestObject./*[a]*/CreateInstance/*[/a]*/();
22
23 // Accept changes.
24 //
25 obj.FirstName = "Tester";
26 obj.LastName = "Testerson";
27
28 Assert.IsTrue(obj.IsDirty);
29
30 obj./*[a]*/AcceptChanges/*[/a]*/();
31
32 Assert.AreEqual("Tester", obj.FirstName);
33 Assert.IsFalse(obj.IsDirty);
34
35 // Reject changes.
36 //
37 obj.FirstName = "Developer";
38
39 Assert.IsTrue(obj.IsDirty);
40
41 obj./*[a]*/RejectChanges/*[/a]*/();
42
43 Assert.AreEqual("Tester", obj.FirstName);
44 Assert.IsFalse(obj.IsDirty);
45 }
46 }
47 }