Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 3
0
        public void HasNextTrueWhenInitialRun()
        {
            StepContext previous = new StepContext();
            StepContext current = StepContext.InitialRun(previous, chunkSize: 2);

            Assert.That(current.HasNext, Is.True);
        }
Esempio n. 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);
        }
Esempio n. 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;
        }
Esempio n. 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>()));
        }
Esempio n. 7
0
 public void HasNextTrueWhenItemSkipped()
 {
     StepContext ctx = new StepContext {Skip = true};
     Assert.That(ctx.HasNext, Is.True);
 }
Esempio n. 8
0
 public void HasNextBasedOnNumberOfItemsReceived(int numOfItemsReceived, bool hasNext)
 {
     StepContext ctx = new StepContext {NumberOfItemsReceived = numOfItemsReceived, ChunkSize = 2};
     Assert.That(ctx.HasNext, Is.EqualTo(hasNext));
 }