Esempio n. 1
0
        public void ShouldPassAfter2RepeatsAndTimeoutIsResetEachTime()
        {
            // Rather than testing with sleeps, this tests that the execution will occur in the correct
            // order by checking which commands are run when. As the repeat command comes first, the
            // timeout will be reset each time it runs
            var            test    = TestBuilder.MakeTestFromMethod(typeof(HelperMethodForTimeoutsClass), nameof(HelperMethodForTimeoutsClass.ShouldPassAfter2RepeatsAndTimeoutIsResetEachTime));
            SimpleWorkItem work    = TestBuilder.CreateWorkItem(test) as SimpleWorkItem;
            var            method  = typeof(SimpleWorkItem).GetMethod("MakeTestCommand", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
            TestCommand    command = (TestCommand)method.Invoke(work, null);

            Assert.That(command, Is.TypeOf(typeof(RepeatAttribute.RepeatedTestCommand)));
            RepeatAttribute.RepeatedTestCommand repeatedCommand = (RepeatAttribute.RepeatedTestCommand)command;

            command = GetInnerCommand(repeatedCommand);

            Assert.That(command, Is.TypeOf(typeof(TimeoutCommand)));
            TimeoutCommand timeoutCommand = (TimeoutCommand)command;

            command = GetInnerCommand(timeoutCommand);

            Assert.That(command, Is.TypeOf(typeof(ApplyChangesToContextCommand)));
            ApplyChangesToContextCommand applyChangesToContextCommand = (ApplyChangesToContextCommand)command;

            command = GetInnerCommand(applyChangesToContextCommand);

            Assert.That(command, Is.TypeOf(typeof(TestMethodCommand)));
        }
 public EnumerableRepeatedTestCommand(RepeatAttribute.RepeatedTestCommand commandToReplace) : base(commandToReplace.GetInnerCommand())
 {
     repeatCount = (int)typeof(RepeatAttribute.RepeatedTestCommand)
                   .GetField("repeatCount", BindingFlags.NonPublic | BindingFlags.Instance)
                   .GetValue(commandToReplace);
 }