Beispiel #1
0
        public void Validate_WhenCalled_ReturnsValidator()
        {
            IUpdateAccountGroupCommand sut = CreateSut();

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

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
Beispiel #2
0
        public void Validate_WhenAccountingRepositoryIsNull_ThrowsArgumentNullException()
        {
            IUpdateAccountGroupCommand 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_AssertUpdateAccountGroupAsyncWasCalledOnAccountingRepository()
        {
            CommandHandler sut = CreateSut();

            IAccountGroup accountGroup         = _fixture.BuildAccountGroupMock().Object;
            IUpdateAccountGroupCommand command = CreateCommandMock(accountGroup).Object;
            await sut.ExecuteAsync(command);

            _accountingRepositoryMock.Verify(m => m.UpdateAccountGroupAsync(It.Is <IAccountGroup>(value => value == accountGroup)), Times.Once);
        }
Beispiel #4
0
        public void Validate_WhenCalled_AssertShouldBeKnownValueWasCalledOnObjectValidator()
        {
            int number = _fixture.Create <int>();
            IUpdateAccountGroupCommand sut = CreateSut(number);

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

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