本文整理汇总了C#中Province.AcceptChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Province.AcceptChanges方法的具体用法?C# Province.AcceptChanges怎么用?C# Province.AcceptChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Province
的用法示例。
在下文中一共展示了Province.AcceptChanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CRUDProvince
public void CRUDProvince()
{
// Insert
var province = new Province
{
};
Assert.IsTrue(!province.IsValid
&& !string.IsNullOrEmpty(province.ValidationMessage)
&& province.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_EmptyName")));
Assert.IsTrue(!province.IsValid
&& !string.IsNullOrEmpty(province.ValidationMessage)
&& province.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_EmptyCreatedBy")));
Assert.IsTrue(!province.IsValid
&& !string.IsNullOrEmpty(province.ValidationMessage)
&& province.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_EmptyStateID")));
province.Name = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
province.CreatedBy = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456";
var state = StateEntity.GetAll().FirstOrDefault();
if (state == null)
Assert.Inconclusive();
province.StateID = state.ID;
Assert.IsTrue(!province.IsValid
&& !string.IsNullOrEmpty(province.ValidationMessage)
&& province.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_MaxNameLength")));
Assert.IsTrue(!province.IsValid
&& !string.IsNullOrEmpty(province.ValidationMessage)
&& province.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_MaxCreatedByLength")));
province.Name = "New temporal province";
province.CreatedBy = "dcruz";
Assert.IsTrue(province.IsValid);
Assert.IsTrue(province.IsNew);
province.AcceptChanges();
Assert.IsTrue(province.IsValid);
Assert.IsTrue(!province.IsChanged);
var loaded = Province.Load(province.ID);
Assert.IsNotNull(loaded);
Assert.IsTrue(!loaded.IsChanged);
Assert.IsTrue(!loaded.IsNew);
Compare(loaded, province);
// Update
loaded.Name = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890";
Assert.IsTrue(!loaded.IsValid
&& !string.IsNullOrEmpty(loaded.ValidationMessage)
&& loaded.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_MaxNameLength")));
Assert.IsTrue(!loaded.IsValid
&& !string.IsNullOrEmpty(loaded.ValidationMessage)
&& loaded.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_EmptyLastUpdatedBy")));
var any = Province.GetProvinces(loaded.StateID).Where(m => m.ID != loaded.ID).FirstOrDefault();
if (any == null)
Assert.Inconclusive();
loaded.Name = any.Name;
Assert.IsTrue(!loaded.IsValid
&& !string.IsNullOrEmpty(loaded.ValidationMessage)
&& loaded.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_DuplicatedName", new { loaded.Name })));
Assert.IsTrue(!loaded.IsValid
&& !string.IsNullOrEmpty(loaded.ValidationMessage)
&& loaded.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_EmptyLastUpdatedBy")));
loaded.Name = "New temporal state 2";
loaded.LastUpdatedBy = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456";
Assert.IsTrue(!loaded.IsValid
&& !string.IsNullOrEmpty(loaded.ValidationMessage)
&& loaded.ValidationMessage.Contains(ResourceStringLoader.GetResourceString("Province_MaxLastUpdatedByLength")));
loaded.LastUpdatedBy = "dcruz";
Assert.IsTrue(loaded.IsChanged);
Assert.IsTrue(loaded.IsValid);
loaded.AcceptChanges();
Assert.IsTrue(!loaded.IsChanged);
Assert.IsTrue(loaded.IsValid);
//.........这里部分代码省略.........