public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException()
        {
            IDeleteAccountingCommand sut = CreateSut();

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

            Assert.That(result.ParamName, Is.EqualTo("commonRepository"));
        }
        public void Validate_WhenCalled_ReturnsValidator()
        {
            IDeleteAccountingCommand sut = CreateSut();

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

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
Ejemplo n.º 3
0
        public async Task ExecuteAsync_WhenCalled_AssertDeleteAccountingAsyncWasCalledOnAccountingRepository()
        {
            CommandHandler sut = CreateSut();

            int accountingNumber             = _fixture.Create <int>();
            IDeleteAccountingCommand command = CreateCommandMock(accountingNumber).Object;
            await sut.ExecuteAsync(command);

            _accountingRepositoryMock.Verify(m => m.DeleteAccountingAsync(It.Is <int>(value => value == accountingNumber)), Times.Once);
        }
        public void Validate_WhenCalled_AssertShouldBeDeletableWasCalledOnObjectValidator()
        {
            int accountingNumber         = _fixture.Create <int>();
            IDeleteAccountingCommand sut = CreateSut(accountingNumber);

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

            _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeDeletable(
                                                                 It.Is <int>(value => value == accountingNumber),
                                                                 It.IsNotNull <Func <int, Task <IAccounting> > >(),
                                                                 It.Is <Type>(type => type == sut.GetType()),
                                                                 It.Is <string>(field => string.Compare(field, "AccountingNumber", false) == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once());
        }