public void Validate_WhenCalled_ReturnsValidator() { ICreatePaymentTermCommand sut = CreateSut(); IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object); Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object)); }
public void Validate_WhenAccountingRepositoryIsNull_ThrowsArgumentNullException() { ICreatePaymentTermCommand sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null)); Assert.That(result.ParamName, Is.EqualTo("accountingRepository")); }
public async Task ExecuteAsync_WhenCalled_AssertCreatePaymentTermAsyncWasCalledOnAccountingRepository() { CommandHandler sut = CreateSut(); IPaymentTerm paymentTerm = _fixture.BuildPaymentTermMock().Object; ICreatePaymentTermCommand command = CreateCommandMock(paymentTerm).Object; await sut.ExecuteAsync(command); _accountingRepositoryMock.Verify(m => m.CreatePaymentTermAsync(It.Is <IPaymentTerm>(value => value == paymentTerm)), Times.Once); }
public void Validate_WhenCalled_AssertShouldBeUnknownValueWasCalledOnObjectValidator() { int number = _fixture.Create <int>(); ICreatePaymentTermCommand sut = CreateSut(number); sut.Validate(_validatorMockContext.ValidatorMock.Object, _accountingRepositoryMock.Object); _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeUnknownValue( It.Is <int>(value => value == number), It.IsNotNull <Func <int, Task <bool> > >(), It.Is <Type>(type => type == sut.GetType()), It.Is <string>(field => string.CompareOrdinal(field, "Number") == 0), It.Is <bool>(value => value == false)), Times.Once()); }