示例#1
0
        public void IncrementTest()
        {
            StepContext previous = new StepContext { StepIndex = 4, ChunkSize = 2};

            StepContext current = StepContext.Increment(previous, 1, 1, false);
            Assert.That(current.StepIndex, Is.EqualTo(6));
        }
示例#2
0
        public void IfPreviousAttemptWasTheFirstAttempThenRetryFirstItem()
        {
            StepContext previous = new StepContext { NumberOfItemsProcessed = 0, StepIndex = 0 };
            StepContext current = StepContext.InitialRun(previous, chunkSize: 2);

            Assert.That(current.StepIndex, Is.EqualTo(0));
        }
示例#3
0
        public void HasNextTrueWhenInitialRun()
        {
            StepContext previous = new StepContext();
            StepContext current = StepContext.InitialRun(previous, chunkSize: 2);

            Assert.That(current.HasNext, Is.True);
        }
示例#4
0
        public void IfPreviousAttemptWasFailureThenRetryDuringRestart()
        {
            StepContext previous = new StepContext { NumberOfItemsProcessed = 0, StepIndex = 4};

            StepContext current = StepContext.InitialRun(previous, chunkSize: 2);

            Assert.That(current.StepIndex, Is.EqualTo(2));
            Assert.IsTrue(current.IsInitialRun);
        }
示例#5
0
        public bool Process(StepContext stepContext, IStepRepository stepRepository)
        {
            // Create a new target folder, if necessary.
            if (!Directory.Exists(_targetPath))
                Directory.CreateDirectory(_targetPath);

            string destinationFile = Path.Combine(_targetPath, _fileName);

            // Copy the file to dest location and overwriter the destination file if it already exists.
            File.Copy(_source, destinationFile, true);

            return true;
        }
示例#6
0
        public void SkippableExceptionsAreSkipped()
        {
            var step = FakeStep<string, string>.Create("step1");
            step.SkipLimit(1)
                .SkippableExceptions(typeof (FlatFileParseException), typeof (Exception));

            step.MockReader.Setup(r => r.Read(0, 1)).Throws<FlatFileParseException>();

            var stepContext = new StepContext {StepName = "step1"};
            step.Process(stepContext, _jobRepo.Object);

            _jobRepo.Verify(j => j.GetExceptionCount(It.Is<SkipContext>(ctx => ctx.StepName == "step1")));
            _jobRepo.Verify(j => j.SaveExceptionInfo(It.IsAny<SkipContext>(), It.IsAny<int>()));
        }
示例#7
0
 public void HasNextTrueWhenItemSkipped()
 {
     StepContext ctx = new StepContext {Skip = true};
     Assert.That(ctx.HasNext, Is.True);
 }
示例#8
0
 public void HasNextBasedOnNumberOfItemsReceived(int numOfItemsReceived, bool hasNext)
 {
     StepContext ctx = new StepContext {NumberOfItemsReceived = numOfItemsReceived, ChunkSize = 2};
     Assert.That(ctx.HasNext, Is.EqualTo(hasNext));
 }