Ejemplo n.º 1
0
        public void ShouldReturnBuiltCommandIfNoVerificationErrorsFound()
        {
            var validatorMock = new Mock <IValidator <CommandBase> >();

            validatorMock.Setup(validator => validator.Validate(It.IsAny <object>()))
            .Returns(new ValidationResult());
            var commandMock = new Mock <CommandBase>();

            commandMock.Setup(command => command.CreateValidator()).Returns(validatorMock.Object);
            var builder = new TestCommandBuilder(commandMock.Object);

            Func <CommandBase> build = () => builder.Build();

            build.Should().NotThrow().Which.Should().BeSameAs(commandMock.Object);
        }
Ejemplo n.º 2
0
        public void ShouldVerifyCommand()
        {
            var validatorMock = new Mock <IValidator <CommandBase> >();

            validatorMock.Setup(validator => validator.Validate(It.IsAny <object>()))
            .Returns(new ValidationResult());
            var commandMock = new Mock <CommandBase>();

            commandMock.Setup(command => command.CreateValidator()).Returns(validatorMock.Object);
            var builder = new TestCommandBuilder(commandMock.Object);

            builder.Build();

            commandMock.Verify(command => command.CreateValidator(), Times.Once());
        }
Ejemplo n.º 3
0
        public void ShouldThrowWithErrorsIfAnyFound()
        {
            var validatorMock = new Mock <IValidator <CommandBase> >();

            validatorMock.Setup(validator => validator.Validate(It.IsAny <object>()))
            .Returns(
                new ValidationResult(
                    new[]
            {
                new ValidationFailure("not-important", "error1"),
                new ValidationFailure("not-important", "error2")
            }));
            var commandMock = new Mock <CommandBase>();

            commandMock.Setup(command => command.CreateValidator()).Returns(validatorMock.Object);
            var builder = new TestCommandBuilder(commandMock.Object);

            Action build = () => builder.Build();

            build.Should().ThrowExactly <CommandBuildException>()
            .Which.Errors.Should().Contain("error1").And.Contain("error2");
            build.Should().ThrowExactly <CommandBuildException>()
            .Which.Message.Should().Contain("error1").And.Contain("error2");
        }
 public EditorEnumeratorTestWorkItem(TestMethod test, ITestFilter filter)
     : base(test, null)
 {
     m_Command = TestCommandBuilder.BuildTestCommand(test, filter);
 }