Пример #1
0
 public ISequenceSpecification TheRest()
 {
     if (FirstInSequence)
     {
         SequenceSpecification.First <IStartupTask>();
     }
     else
     {
         SequenceSpecification.Then <IStartupTask>();
     }
     return(SequenceSpecification);
 }
Пример #2
0
        public void ShouldReturnANonFirstInSequenceSequenceSpecial()
        {
            //Arrange
            var spec = new SequenceSpecification();

            //Act
            var result = spec.Then();

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(ISequenceSpecial));
            Assert.IsInstanceOfType(result, typeof(SequenceSpecial));
            Assert.AreSame(spec, result.SequenceSpecification);
            Assert.AreEqual(false, result.FirstInSequence);
        }
Пример #3
0
        public void ShouldAddATaskToTheBottomOfTheSequence()
        {
            //Arrange
            var spec = new SequenceSpecification();

            spec.Sequence.Add(new TaskExecutionParameters {
                TaskType = typeof(TaskAlpha)
            });
            spec.Sequence.Add(new TaskExecutionParameters {
                TaskType = typeof(TaskBeta)
            });

            //Act
            spec.Then <TaskOmega>();
            var result = spec.Sequence;

            //Assert
            Assert.AreEqual(3, result.Count);
            Assert.AreSame(typeof(TaskOmega), result[result.Count - 1].TaskType);
        }
Пример #4
0
        public void ShouldSetTheDelayForTheMiddleTask()
        {
            //Arrange
            var spec = new SequenceSpecification();

            //Act
            var result = spec.Then <TaskAlpha>().DelayStartBy(5)
                         .Then <TaskBeta>().DelayStartBy(10).Seconds
                         .Then <TaskOmega>().DelayStartBy(15).MilliSeconds
                         .Then().TheRest().DelayStartBy(20)
                         .Then <TestStartupTask>()
                         .Sequence;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(List <TaskExecutionParameters>));
            Assert.AreEqual(0, result.First(t => t.TaskType == typeof(TestStartupTask)).Delay);
            Assert.AreEqual(20, result.First(t => t.TaskType == typeof(IStartupTask)).Delay);
            Assert.AreEqual(15, result.First(t => t.TaskType == typeof(TaskOmega)).Delay);
            Assert.AreEqual(10000, result.First(t => t.TaskType == typeof(TaskBeta)).Delay);
            Assert.AreEqual(5, result.First(t => t.TaskType == typeof(TaskAlpha)).Delay);
        }