Example #1
0
        public void ThreeWorkflows_Start_RunsAndLogsThreeWorkflows()
        {
            var logger = new MockLogger();
            var engine = new WorkflowEngine(logger);

            var workflow1 = new MockWorkflow();
            var workflow2 = new MockWorkflow();
            var workflow3 = new MockWorkflow();
            var workflows = new MockWorkflow[] { workflow1, workflow2, workflow3 };

            engine.Start(workflows);

            var starting = "Starting workflow...";
            var finished = "Finished workflow.";

            IEnumerable<string> expectedLogResult = new string[]
            {
                "Starting all workflows...",
                starting,
                finished,
                starting,
                finished,
                starting,
                finished,
                "Finished all workflows."
            };
            IEnumerable<string> actualLogResult = logger.GetLogContents();

            Assert.IsTrue(expectedLogResult.SequenceEqual(actualLogResult));
            foreach (var wf in workflows)
            {
                Assert.AreEqual(1, wf.TimesRun);
            }
        }
Example #2
0
        public void OneWorkflow_Start_RunsAndLogsOneWorkflow()
        {
            var logger = new MockLogger();
            var engine = new WorkflowEngine(logger);

            var workflow = new MockWorkflow();
            var workflows = new MockWorkflow[] { workflow };
            engine.Start(workflows);

            IEnumerable<string> expectedLogResult = new string[]
            {
                "Starting all workflows...",
                "Starting workflow...",
                "Finished workflow.",
                "Finished all workflows."
            };
            IEnumerable<string> actualLogResult = logger.GetLogContents();

            Assert.IsTrue(expectedLogResult.SequenceEqual(actualLogResult));
            Assert.AreEqual(1, workflow.TimesRun);
        }