public void Validate_WhenCalled_ReturnsValidator() { IIdentityIdentificationCommand sut = CreateSut(); IValidator result = sut.Validate(_validatorMockContext.ValidatorMock.Object, _securityRepositoryMock.Object); Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object)); }
public void Validate_WhenSecurityRepositoryIsNull_ThrowsArgumentNullException() { IIdentityIdentificationCommand sut = CreateSut(); ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null)); Assert.That(result.ParamName, Is.EqualTo("securityRepository")); }
public async Task ExecuteAsync_WhenCalled_AssertManageRepositoryAsyncWasCalledWithSameCommand() { CommandHandler sut = CreateSut(); IIdentityIdentificationCommand command = CreateCommandMock().Object; await sut.ExecuteAsync(command); Assert.That(((Sut)sut).Command, Is.EqualTo(command)); }
protected override Task ManageRepositoryAsync(IIdentityIdentificationCommand command) { NullGuard.NotNull(command, nameof(command)); return(Task.Run(() => { ManageRepositoryAsyncWasCalled = true; Command = command; })); }
public void Validate_WhenCalled_AssertShouldBeGreaterThanZeroWasCalledOnIntegerValidator() { int identifier = _fixture.Create <int>(); IIdentityIdentificationCommand sut = CreateSut(identifier); sut.Validate(_validatorMockContext.ValidatorMock.Object, _securityRepositoryMock.Object); _validatorMockContext.IntegerValidatorMock.Verify(m => m.ShouldBeGreaterThanZero( It.Is <int>(value => value == identifier), It.Is <Type>(type => type == sut.GetType()), It.Is <string>(field => string.Compare(field, "Identifier", false) == 0)), Times.Once()); }