本文整理汇总了C#中Computer.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# Computer.Commit方法的具体用法?C# Computer.Commit怎么用?C# Computer.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Computer
的用法示例。
在下文中一共展示了Computer.Commit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Set_test
public void Set_test()
{
// arrange
var maker = "Intel";
var processorSpeed = 500;
var ramSize = 2000;
processors[0] = new Dictionary<string, object>
{
{ "Maker", maker},
{ "Speed", processorSpeed}
};
rams[0] = new Dictionary<string, object>
{
{ "Size", ramSize }
};
var processor = new Processor(0, processorCollectionMock.Object);
var ram = new RAM(0, ramCollectionMock.Object);
var computer = new Computer(aggregatorProviderMock.Object, processor, ram);
// act
var newRamSize = 1;
computer.RAMSize = newRamSize;
computer.Commit();
// assert
rams[0]["Size"].Should().Be(newRamSize);
}
示例2: Set_test
public void Set_test()
{
// arrange
var maker = "Intel";
var processorSpeed = 500;
var ramSize = 2000;
processors[0] = new Dictionary<string, object>
{
{ "Maker", maker},
{ "Speed", processorSpeed},
{ "RamId", 0 }
};
rams[0] = new Dictionary<string, object>
{
{ "Size", ramSize }
};
var aggregatorProvider = aggregatorProviderMock.Object;
var processorModel = new ProcessorModel(0, processorCollectionMock.Object);
var ramModel = new RAMModel(0, ramCollectionMock.Object);
var computer = new Computer(aggregatorProvider, processorModel);
var ram = new RAM(aggregatorProvider, ramModel);
aggregatorProvider.Save(computer, ram);
// act
var newMaker = "AMD";
var newProcessorSpeed = 1000;
var newRamSize = 3000;
computer.RAM.Size = newRamSize;
computer.ProcessorSpeed = newProcessorSpeed;
computer.Maker = newMaker;
computer.Commit();
// assert
processors[0]["Maker"].Should().Be(newMaker);
processors[0]["Speed"].Should().Be(newProcessorSpeed);
rams[0]["Size"].Should().Be(newRamSize);
processorCollectionMock.Verify(x =>
x.UpdateFields(It.IsAny<Id>(), It.IsAny<IDictionary<string, object>>()),
Times.Once);
ramCollectionMock.Verify(x =>
x.UpdateFields(It.IsAny<Id>(), It.IsAny<IDictionary<string, object>>()),
Times.Once);
}