public void Validate_WhenCalled_ReturnsValidator() { IDeleteAccountCommand sut = CreateSut(); IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object, _commonRepositoryMock.Object); Assert.That(result, Is.SameAs(_validatorMockContext.ValidatorMock.Object)); }
public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException() { IDeleteAccountCommand sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object, null)); Assert.That(result.ParamName, Is.EqualTo("commonRepository")); }
public async Task ExecuteAsync_WhenCalled_AssertDeleteAccountAsyncWasCalledOnAccountingRepository() { CommandHandler sut = CreateSut(); int accountingNumber = _fixture.Create <int>(); string accountNumber = _fixture.Create <string>(); IDeleteAccountCommand command = CreateCommand(accountingNumber, accountNumber); await sut.ExecuteAsync(command); _accountingRepositoryMock.Verify(m => m.DeleteAccountAsync( It.Is <int>(value => value == accountingNumber), It.Is <string>(value => string.CompareOrdinal(value, accountNumber) == 0)), Times.Once); }
public void Validate_WhenCalled_AssertShouldBeDeletableWasCalledOnObjectValidatorWithAccountNumber() { string accountNumber = _fixture.Create <string>().ToUpper(); IDeleteAccountCommand sut = CreateSut(accountNumber); sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object, _commonRepositoryMock.Object); _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeDeletable( It.Is <string>(value => string.CompareOrdinal(value, accountNumber) == 0), It.IsNotNull <Func <string, Task <IAccount> > >(), It.Is <Type>(type => type == sut.GetType()), It.Is <string>(field => string.CompareOrdinal(field, "AccountNumber") == 0), It.Is <bool>(allowNull => allowNull == false)), Times.Once); }