本文整理匯總了C#中System.Foo.Commit方法的典型用法代碼示例。如果您正苦於以下問題:C# Foo.Commit方法的具體用法?C# Foo.Commit怎麽用?C# Foo.Commit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Foo
的用法示例。
在下文中一共展示了Foo.Commit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AreSetEventEnabled_disables_events
public void AreSetEventEnabled_disables_events()
{
// arrange
var prevField1 = default(string);
var prevField2 = default(DateTime);
var field1 = "test";
var field2 = DateTime.UtcNow;
storage[0] = new Dictionary<string, object>{
{"Field1", prevField1},
{"Field2", prevField2}
};
var foo = new Foo(0, dBCollectionMock.Object);
// act
foo.AreSetEventsEnabled = false;
foo.Field1 = field1;
foo.Field2 = field2;
foo.Commit();
// assert
storage[0]["Field1"].Should().Be(prevField1);
storage[0]["Field2"].Should().Be(prevField2);
foo.Field1.Should().Be(field1);
foo.Field2.Should().Be(field2);
}
示例2: Commit_applies_changes_to_model
public void Commit_applies_changes_to_model()
{
// arrange
storage[0] = new Dictionary<string, object>{
{"Field1", default(string)},
{"Field2", default(DateTime)}
};
var foo = new Foo(0, dBCollectionMock.Object);
// act
var field1 = "test";
var field2 = DateTime.UtcNow;
foo.Field1 = field1;
foo.Field2 = field2;
foo.Commit();
// assert
storage[0]["Field1"].Should().Be(field1);
storage[0]["Field2"].Should().Be(field2);
dBCollectionMock.Verify(x =>
x.UpdateFields(0, It.IsAny<IDictionary<string, object>>()), Times.Once);
}