本文整理汇总了C#中Person.CancelEdit方法的典型用法代码示例。如果您正苦于以下问题:C# Person.CancelEdit方法的具体用法?C# Person.CancelEdit怎么用?C# Person.CancelEdit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person.CancelEdit方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MultiEditUndoSuccess
public void MultiEditUndoSuccess()
{
UnitTestContext context = GetContext();
Person p = new Person();
p.Age = 1;
p.BeginEdit();
p.Age = 2;
p.BeginEdit();
p.Age = 3;
context.Assert.AreEqual(3, p.Age);
p.CancelEdit();
context.Assert.AreEqual(2, p.Age);
p.CancelEdit();
context.Assert.AreEqual(1, p.Age);
context.Assert.Success();
context.Complete();
}
示例2: EditUndoSuccess
public void EditUndoSuccess()
{
UnitTestContext context = GetContext();
int expected = 1;
Person p = new Person();
p.Age = expected;
p.BeginEdit();
p.Age = 2;
p.CancelEdit();
context.Assert.AreEqual(expected, p.Age);
context.Assert.Success();
context.Complete();
}
示例3: InvalidUndo
public void InvalidUndo()
{
UnitTestContext context = GetContext();
Person p = new Person();
p.CancelEdit();
context.Assert.Success();
context.Complete();
}
示例4: UndoUninitializedValues
public void UndoUninitializedValues()
{
UnitTestContext context = GetContext();
Person p = new Person();
// p.Age; calling this property initializes it! So set it explicitly.
int expected = (DateTime.Now - new DateTime(1, 1, 1)).Days / 365; //2008;
p.BeginEdit();
p.Age = 100;
p.CancelEdit();
context.Assert.AreEqual(expected, p.Age);
context.Assert.Success();
context.Complete();
}
示例5: UndoWithDeleteAddToList
public void UndoWithDeleteAddToList()
{
UnitTestContext context = GetContext();
Person p = new Person();
p.Addresses = new AddressList();
Address a = new Address();
a.ZipCode = "0";
p.Addresses.Add(a);
Address a1 = new Address();
a1.ZipCode = "1";
p.Addresses.Add(a1);
int age1 = p.Age;
string city1 = a.City;
p.BeginEdit();
int age2 = p.Age = 2;
string city2 = a.City = "two";
p.Addresses[0].ZipCode = "000";
Address a2 = new Address();
a2.ZipCode = "2";
p.Addresses.Add(a2);
Address a3 = new Address();
a3.ZipCode = "3";
p.Addresses.Add(a3);
p.Addresses.RemoveAt(0);
context.Assert.AreEqual(age2, p.Age);
context.Assert.AreEqual(city2, a.City);
p.CancelEdit();
context.Assert.AreEqual(age1, p.Age);
context.Assert.AreEqual(city1, a.City);
context.Assert.AreEqual("0", a.ZipCode);
context.Assert.AreEqual(2, p.Addresses.Count);
context.Assert.Success();
context.Complete();
}
示例6: UndoAfterApplyEditFail
public void UndoAfterApplyEditFail()
{
UnitTestContext context = GetContext();
Person p = new Person();
p.BeginEdit();
p.ApplyEdit();
p.CancelEdit();
context.Assert.Success();
context.Complete();
}
示例7: UndoChildSuccess
public void UndoChildSuccess()
{
UnitTestContext context = GetContext();
Person p = new Person();
p.Addresses = new AddressList();
Address a = new Address();
p.Addresses.Add(a);
int age1 = p.Age = 1;
string city1 = a.City = "one";
p.BeginEdit();
int age2 = p.Age = 2;
string city2 = a.City = "two";
a.BeginEdit();
string city3 = a.City = "three";
a.CancelEdit();
context.Assert.AreEqual(age2, p.Age);
context.Assert.AreEqual(city2, a.City);
p.CancelEdit();
context.Assert.AreEqual(age1, p.Age);
context.Assert.AreEqual(city1, a.City);
context.Assert.Success();
context.Complete();
}
示例8: ApplyChildAfterRootUndo
public void ApplyChildAfterRootUndo()
{
UnitTestContext context = GetContext();
Person p = new Person();
p.Addresses = new AddressList();
Address a = new Address();
p.Addresses.Add(a);
p.BeginEdit();
p.CancelEdit();
a.ApplyEdit();
context.Assert.Success();
context.Complete();
}
示例9: UndoChildFail
public void UndoChildFail()
{
UnitTestContext context = GetContext();
Person p = new Person();
p.Addresses = new AddressList();
Address a = new Address();
p.Addresses.Add(a);
p.BeginEdit();
p.CancelEdit();
a.CancelEdit();
context.Assert.Success();
context.Complete();
}