public void ShouldSimulateCompleteWorkflow()
        {
            DataAccess.TableEntityDataAccess tda = new DataAccess.TableEntityDataAccess(Connection());
            var person       = tda.GetTableAndColumns("Person", "NewPerson");
            var personDetail = tda.GetTableAndColumns("Person", "AnotherTable");

            personDetail.Columns.First().Generator = new ValueFromOtherColumnIntGenerator(personDetail.Columns.First().ColumnDataType);
            personDetail.Columns.First().Generator.GeneratorParameters.ValueFromOtherColumn.Value = person.Columns.First();

            ExecutionNode node = ExecutionNode.CreateLevelOneNode(100, "Root");

            node.AddTable(person);
            node.AddTable(personDetail);

            var consumerMeta   = PluginLoader.GetMetaDataOfType(typeof(InsertConsumer));
            var wrapper        = new DataConsumerPluginWrapper(consumerMeta.ConsumerName, typeof(InsertConsumer), consumerMeta.OptionsTemplate);
            ExecutionResultBuilder builder = new ExecutionResultBuilder();

            WorkflowManager manager = new WorkflowManager();

            manager.RunWorkFlow(Connection(), wrapper, builder, options, node);
            var result = builder.Build();

            Assert.That(result.InsertCount, Is.EqualTo(200));
            Assert.That(result.Errors.Count, Is.EqualTo(0));
            Assert.That(result.Duration, Is.GreaterThan(new TimeSpan(1)));
        }
        public void ShouldNotBeAbleToPerformActionsOnBuilderBeforeStaringIt()
        {
            ExecutionResultBuilder builder = new ExecutionResultBuilder();

            ExpectedExceptionHappened <InvalidOperationException>(new Action(() => { builder.Increment(); }), "should throw exception if using un-initialized builder");
            ExpectedExceptionHappened <InvalidOperationException>(new Action(() => { builder.AddError(new ArgumentNullException(), null); }), "should throw exception if using un-initialized builder");
            ExpectedExceptionHappened <InvalidOperationException>(new Action(() => { builder.Build(); }), "should throw exception if using un-initialized builder");
        }
Ejemplo n.º 3
0
        public void ShouldInstantiateWorkflowManager()
        {
            builder = new ExecutionResultBuilder().Begin();
            ExecutionNode rootNode = ExecutionNode.CreateLevelOneNode(1, "Root");

            manager.RunWorkFlow(connectionString, wrapper, builder, options, rootNode);

            var result = builder.Build();

            Assert.That(result.Errors.Count, Is.EqualTo(0), "error count");
            Assert.That(result.InsertCount, Is.EqualTo(0), "insert count");
        }
        public void ShouldResetAllValuesIfCallingBeginSeveralTimes()
        {
            ExecutionResultBuilder builder = new ExecutionResultBuilder();

            builder.Begin();
            builder.Increment();
            builder.Increment();
            builder.Increment();
            builder.AddError(new Exception(), null);
            var result = builder.Build();

            Assert.That(result.InsertCount, Is.EqualTo(3));
            Assert.That(result.Errors.Count, Is.EqualTo(1));

            ExpectedExceptionHappened <InvalidOperationException>(new Action(() => { builder.Build(); }), "should not be able to build again before calling begin");

            builder.Begin();
            builder.Increment();
            var result2 = builder.Build();

            Assert.That(result2.InsertCount, Is.EqualTo(1));
            Assert.That(result2.Errors.Count, Is.EqualTo(0));
        }
Ejemplo n.º 5
0
        public void ShouldRunWorkflowAsync()
        {
            builder = new ExecutionResultBuilder().Begin();
            ExecutionNode rootNode = ExecutionNode.CreateLevelOneNode(1, "Root");

            rootNode.AddTable(new TableEntity("dbo", "Customer"));

            manager.RunWorkFlowAsync(connectionString, wrapper, builder, options, rootNode);
            Thread.Sleep(10); // give some time for the async method to complete
            var result = builder.Build();

            Assert.That(result.Errors.Count, Is.EqualTo(0));
            Assert.That(result.InsertCount, Is.EqualTo(1));
        }
Ejemplo n.º 6
0
        public void ShouldConsumeOneRow()
        {
            builder = new ExecutionResultBuilder();
            builder.Begin();
            ExecutionNode rootNode = ExecutionNode.CreateLevelOneNode(1, "Root");

            rootNode.AddTable(new TableEntity("dbo", "Customer"));

            manager.RunWorkFlow(connectionString, wrapper, builder, options, rootNode);

            var result = builder.Build();

            Assert.That(result.Errors.Count, Is.EqualTo(0));
            Assert.That(result.InsertCount, Is.EqualTo(1));
        }
        public void ShouldStartAndBuildBuilder()
        {
            ExecutionResultBuilder builder = new ExecutionResultBuilder();

            builder.Begin();
            builder.AddError(new Exception(), new DataRowEntity(null));
            Thread.Sleep(1); // to get different enddate than startdate
            builder.Increment();

            ExecutionResult result = builder.Build();

            Assert.That(result.InsertCount, Is.EqualTo(1));
            Assert.That(result.Errors.Count, Is.EqualTo(1));
            Assert.That(result.Duration, Is.Not.Null);
            Assert.That(result.StartTime, Is.Not.Null);
            Assert.That(result.EndTime, Is.Not.Null);

            Assert.That(result.EndTime, Is.GreaterThan(result.StartTime));
        }