當前位置: 首頁>>代碼示例>>C#>>正文


C# Machine.Process方法代碼示例

本文整理匯總了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();
            }
        }
開發者ID:trulstveoy,項目名稱:Sandbox,代碼行數:26,代碼來源:ConfigurationTest.cs

示例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);
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:25,代碼來源:MachineTest.cs

示例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());
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:20,代碼來源:MachineTest.cs

示例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);
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:17,代碼來源:MachineTest.cs

示例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());
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:25,代碼來源:MachineTest.cs

示例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());
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:22,代碼來源:MachineTest.cs

示例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));
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:18,代碼來源:MachineTest.cs

示例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);
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:16,代碼來源:MachineTest.cs

示例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());
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:11,代碼來源:MachineTest.cs

示例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));
        }
開發者ID:Krizzzn,項目名稱:DLImageParsr,代碼行數:22,代碼來源:MachineTest.cs


注:本文中的System.Machine.Process方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。