本文整理汇总了C#中Builder.Rollback方法的典型用法代码示例。如果您正苦于以下问题:C# Builder.Rollback方法的具体用法?C# Builder.Rollback怎么用?C# Builder.Rollback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Builder
的用法示例。
在下文中一共展示了Builder.Rollback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Rollback_CallsCommitOnEachBuildStepOnce
public void Rollback_CallsCommitOnEachBuildStepOnce()
{
// Arrange
var buildSteps = new[]
{
Substitute.For<IBuildStep>(),
Substitute.For<IBuildStep>(),
Substitute.For<IBuildStep>()
};
var dependencySorter = Substitute.For<IBuildStepDependencySorter>();
dependencySorter.Sort(Arg.Any<IEnumerable<IBuildStep>>())
.Returns(buildSteps);
var sut = new Builder(dependencySorter)
.With(buildSteps[1])
.With(buildSteps[2])
.With(buildSteps[0]);
// Act
sut.Rollback();
// Assert
buildSteps[0].Received(1).Rollback();
buildSteps[1].Received(1).Rollback();
buildSteps[2].Received(1).Rollback();
}
示例2: Rollback_RunStepsInTheReverseOrderOfDependencies
public void Rollback_RunStepsInTheReverseOrderOfDependencies()
{
var results = new Queue<Tuple<Type, string>>();
Action<Type, string> capture = (t, s) =>
results.Enqueue(new Tuple<Type, string>(t, s));
var buildSteps = new IBuildStep[]
{
new Step1(capture),
new Step2(capture),
};
var dependencySorter = Substitute.For<IBuildStepDependencySorter>();
dependencySorter.Sort(Arg.Any<IEnumerable<IBuildStep>>())
.Returns(buildSteps.Reverse());
var sut = new Builder(dependencySorter)
.With(buildSteps[0])
.With(buildSteps[1]);
sut.Rollback();
var firstStep = results.Dequeue();
firstStep.Item1.Should().Be(typeof(Step1));
firstStep.Item2.Should().Be("Rollback");
var secondStep = results.Dequeue();
secondStep.Item1.Should().Be(typeof(Step2));
secondStep.Item2.Should().Be("Rollback");
results.Count.Should().Be(0);
}