本文整理汇总了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);
}