Пример #1
0
        public void Validate_WhenCalled_ReturnsValidator()
        {
            IAccountGroupIdentificationCommand sut = CreateSut();

            IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object);

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
Пример #2
0
        public void Validate_WhenAccountingRepositoryIsNull_ThrowsArgumentNullException()
        {
            IAccountGroupIdentificationCommand sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null));

            Assert.That(result.ParamName, Is.EqualTo("accountingRepository"));
        }
Пример #3
0
        public async Task ExecuteAsync_WhenCalled_AssertManageRepositoryAsyncWasCalledWithSameCommand()
        {
            CommandHandler sut = CreateSut();

            IAccountGroupIdentificationCommand command = CreateCommandMock().Object;
            await sut.ExecuteAsync(command);

            Assert.That(((Sut)sut).Command, Is.EqualTo(command));
        }
Пример #4
0
            protected override Task ManageRepositoryAsync(IAccountGroupIdentificationCommand command)
            {
                NullGuard.NotNull(command, nameof(command));

                return(Task.Run(() =>
                {
                    ManageRepositoryAsyncWasCalled = true;
                    Command = command;
                }));
            }
Пример #5
0
        public void Validate_WhenCalled_AssertShouldBeBetweenWasCalledOnIntegerValidator()
        {
            int number = _fixture.Create <int>();
            IAccountGroupIdentificationCommand sut = CreateSut(number);

            sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object);

            _validatorMockContext.IntegerValidatorMock.Verify(m => m.ShouldBeBetween(
                                                                  It.Is <int>(value => value == number),
                                                                  It.Is <int>(minValue => minValue == 1),
                                                                  It.Is <int>(maxValue => maxValue == 99),
                                                                  It.Is <Type>(type => type == sut.GetType()),
                                                                  It.Is <string>(field => string.Compare(field, "Number", false) == 0)),
                                                              Times.Once());
        }