コード例 #1
0
        public void Validate_WhenCalled_ReturnsValidator()
        {
            ICreateBudgetAccountGroupCommand sut = CreateSut();

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

            Assert.That(result, Is.EqualTo(_validatorMockContext.ValidatorMock.Object));
        }
コード例 #2
0
        public void Validate_WhenAccountingRepositoryIsNull_ThrowsArgumentNullException()
        {
            ICreateBudgetAccountGroupCommand sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.Validate(_validatorMockContext.ValidatorMock.Object, null));

            Assert.That(result.ParamName, Is.EqualTo("accountingRepository"));
        }
コード例 #3
0
        public async Task ExecuteAsync_WhenCalled_AssertCreateBudgetAccountGroupAsyncWasCalledOnAccountingRepository()
        {
            CommandHandler sut = CreateSut();

            IBudgetAccountGroup budgetAccountGroup   = _fixture.BuildBudgetAccountGroupMock().Object;
            ICreateBudgetAccountGroupCommand command = CreateCommandMock(budgetAccountGroup).Object;
            await sut.ExecuteAsync(command);

            _accountingRepositoryMock.Verify(m => m.CreateBudgetAccountGroupAsync(It.Is <IBudgetAccountGroup>(value => value == budgetAccountGroup)), Times.Once);
        }
コード例 #4
0
        public void Validate_WhenCalled_AssertShouldBeUnknownValueWasCalledOnObjectValidator()
        {
            int number = _fixture.Create <int>();
            ICreateBudgetAccountGroupCommand 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.Compare(field, "Number", false) == 0),
                                                                 It.Is <bool>(allowNull => allowNull == false)),
                                                             Times.Once());
        }