本文整理汇总了C#中System.Machine.Process方法的典型用法代码示例。如果您正苦于以下问题:C# Machine.Process方法的具体用法?C# Machine.Process怎么用?C# Machine.Process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Machine
的用法示例。
在下文中一共展示了Machine.Process方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoIt
public void DoIt()
{
var machine = new Machine(_stateFactory, _persister);
machine.Configure(p => p
.Setup<StateA>(x => x.Reached5)
.Setup<StateA>(x => x.Reaced10)
.TransitionTo<StateB>()
.TransitionTo<StateC>());
machine.Configure(p => p
.Setup<StateB>(x => x.Reached15)
.Setup<StateC>(x => x.Reached20)
.TransitionTo<StateD>());
string descriptions = machine.GetDescriptions();
var fooData = new FooData();
fooData.Id = Guid.NewGuid();
for (int i = 0; i < 50; i++)
{
machine.Process(fooData);
App.Worker.Increase();
}
}
示例2: Process__bubbles_processed_dive_before_saving_dive
public void Process__bubbles_processed_dive_before_saving_dive()
{
var accessed = 0;
var parserMock = new Mock<IImageParser>();
var pixels = new[] { new Pixel(2, 3), new Pixel(3, 4), new Pixel(5, 4) };
parserMock.Setup(d => d.ReadDocument()).Returns(pixels);
var dives = new[] { new Dive(15, 50, 23, ""), new Dive(24, 20, 33, "") };
var dr = new Mock<IDiveRepository>();
dr.Setup(inp => inp.LoadDives()).Returns(dives);
var sf = new Mock<ISampleFactory>();
var processed = new[] { new ProcessedDive(dives[0]), new ProcessedDive(dives[0]) };
sf.Setup(inp => inp.Create(It.IsAny<IEnumerable<Pixel>>(), dives[0])).Returns(processed[0]);
sf.Setup(inp => inp.Create(It.IsAny<IEnumerable<Pixel>>(), dives[1])).Returns(processed[1]);
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { return parserMock.Object; };
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.BeforeSavingDive += (dive) => accessed += dive.DiveLogId;
machine.Process();
accessed.Should().BeGreaterOrEqualTo(25);
}
示例3: Process__disposes_the_image_parser
public void Process__disposes_the_image_parser()
{
var parserMock = new Mock<IImageParser>();
var pixels = new[] { new Pixel(2, 3), new Pixel(3, 4), new Pixel(5, 4) };
parserMock.Setup(d => d.ReadDocument()).Returns(pixels);
var dives = new[] { new Dive(14, 50, 23, "")};
var dr = new Mock<IDiveRepository>();
dr.Setup(inp => inp.LoadDives()).Returns(dives);
var sf = new Mock<ISampleFactory>();
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { return parserMock.Object; };
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.Process();
parserMock.Verify(dd => dd.Dispose(), Times.Once());
}
示例4: Process__raises_message_before_processing_dive
public void Process__raises_message_before_processing_dive()
{
var accessed = 0;
var dives = new[] { new Dive(15, 50, 23, ""), new Dive(24, 20, 33, "") };
var dr = new Mock<IDiveRepository>();
dr.Setup(inp => inp.LoadDives()).Returns(dives);
var sf = new Mock<ISampleFactory>();
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { return new Mock<IImageParser>().Object; };
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.ProcessMessage += (d) => accessed++;
machine.Process();
accessed.Should().BeGreaterOrEqualTo(2);
}
示例5: Process__stores_processed_dives_but_not_nulls
public void Process__stores_processed_dives_but_not_nulls()
{
var accessed = 0;
var parserMock = new Mock<IImageParser>();
var pixels = new[] { new Pixel(2, 3), new Pixel(3, 4), new Pixel(5, 4) };
parserMock.Setup(d => d.ReadDocument()).Returns(pixels);
var dives = new[] { new Dive(14, 50, 23, ""), new Dive(14, 50, 23, "") };
var dr = new Mock<IDiveRepository>();
dr.Setup(inp => inp.LoadDives()).Returns(dives);
var sf = new Mock<ISampleFactory>();
var processed = new[] { new ProcessedDive(dives[0]), null };
sf.Setup(inp => inp.Create(It.IsAny<IEnumerable<Pixel>>(), dives[0])).Returns(processed[0]);
sf.Setup(inp => inp.Create(It.IsAny<IEnumerable<Pixel>>(), dives[1])).Returns(processed[1]);
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { if (dives.Contains(d)) accessed++; return parserMock.Object; };
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.Process();
dr.Verify(inp => inp.SaveDive(It.IsAny<ProcessedDive>() ), Times.Once());
}
示例6: Process__put_pixels_into_SampleFactory
public void Process__put_pixels_into_SampleFactory()
{
var accessed = 0;
var parserMock = new Mock<IImageParser>();
var pixels = new [] { new Pixel(2,3), new Pixel(3,4), new Pixel(5,4) };
parserMock.Setup(d => d.ReadDocument()).Returns(pixels);
var dives = new[] { new Dive(14, 50, 23, ""), new Dive(24, 20, 33, "") };
var dr = new Mock<IDiveRepository>();
dr.Setup(inp => inp.LoadDives()).Returns(dives);
var sf = new Mock<ISampleFactory>();
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { if (dives.Contains(d)) accessed++; return parserMock.Object; };
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.Process();
sf.Verify(inp => inp.Create(pixels, dives[0]), Times.Once());
sf.Verify(inp => inp.Create(pixels, dives[1]), Times.Once());
}
示例7: Process__gets_parses_the_images
public void Process__gets_parses_the_images()
{
var accessed = 0;
var parserMock = new Mock<IImageParser>();
var dives = new[] { new Dive(14, 50, 23, ""), new Dive(24, 20, 33, "") };
var dr = new Mock<IDiveRepository>();
dr.Setup(inp => inp.LoadDives()).Returns(dives);
var sf = new Mock<ISampleFactory>();
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { if (dives.Contains(d)) accessed++; return parserMock.Object; };
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.Process();
parserMock.Verify(d => d.ReadDocument(), Times.Exactly(2));
}
示例8: Process__gets_Image_parser_from_factory_method_but_not_for_null_values
public void Process__gets_Image_parser_from_factory_method_but_not_for_null_values()
{
var accessed = 0;
var dives = new[] { new Dive(15, 50, 23, ""), new Dive(24, 20, 33, ""), null };
var dr = new Mock<IDiveRepository>();
dr.Setup(inp => inp.LoadDives()).Returns(dives);
var sf = new Mock<ISampleFactory>();
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { accessed += d.DiveLogId; return new Mock<IImageParser>().Object; };
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.Process();
accessed.Should().Be(39);
}
示例9: Process__gets_data_from_repository
public void Process__gets_data_from_repository()
{
var dr = new Mock<IDiveRepository>();
var sf = new Mock<ISampleFactory>();
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => new Mock<IImageParser>().Object;
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.Process();
dr.Verify(o => o.LoadDives(), Times.Once());
}
示例10: Process__dont_put_pixels_into_SampleFactory_but_not_for_null_values
public void Process__dont_put_pixels_into_SampleFactory_but_not_for_null_values()
{
var accessed = 0;
var parserMock = new Mock<IImageParser>();
Pixel[] pixels = null;
parserMock.Setup(d => d.ReadDocument()).Returns(pixels);
var dives = new[] { new Dive(14, 50, 23, ""), new Dive(24, 20, 33, "") };
var dr = new Mock<IDiveRepository>();
dr.Setup(inp => inp.LoadDives()).Returns(dives);
var sf = new Mock<ISampleFactory>();
Func<DlImageParsr.Model.Dive, IImageParser> facFunc = d => { if (dives.Contains(d)) accessed++; return parserMock.Object; };
var machine = new Machine(dr.Object, sf.Object, facFunc);
machine.Process();
sf.Verify(inp => inp.Create(pixels, It.IsAny<Dive>()), Times.Never());
parserMock.Verify(inp => inp.Dispose(), Times.Exactly(2));
}