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");
        }
        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));
        }
        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));
        }