public void Validate_WhenCalled_ReturnsValidator() { IDeleteLetterHeadCommand sut = CreateSut(); IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _commonRepositoryMock.Object); Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object)); }
public void Validate_WhenCommonRepositoryIsNull_ThrowsArgumentNullException() { IDeleteLetterHeadCommand sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null)); Assert.That(result.ParamName, Is.EqualTo("commonRepository")); }
public async Task ExecuteAsync_WhenCalled_AssertDeleteLetterHeadAsyncWasCalledOnCommonRepository() { CommandHandler sut = CreateSut(); int number = _fixture.Create <int>(); IDeleteLetterHeadCommand command = CreateCommandMock(number).Object; await sut.ExecuteAsync(command); _commonRepositoryMock.Verify(m => m.DeleteLetterHeadAsync(It.Is <int>(value => value == number)), Times.Once); }
public void Validate_WhenCalled_AssertShouldBeDeletableWasCalledOnObjectValidator() { int number = _fixture.Create <int>(); IDeleteLetterHeadCommand sut = CreateSut(number); sut.Validate(_validatorMockContext.ValidatorMock.Object, _commonRepositoryMock.Object); _validatorMockContext.ObjectValidatorMock.Verify(m => m.ShouldBeDeletable( It.Is <int>(value => value == number), It.IsNotNull <Func <int, Task <ILetterHead> > >(), It.Is <Type>(value => sut.GetType() == value), It.Is <string>(value => string.Compare(value, "Number", StringComparison.Ordinal) == 0), It.Is <bool>(value => value == false)), Times.Once()); }