示例#1
0
        public GetAccountingQueryHandler(IValidator validator, IAccountingRepository accountingRepository, IAccountingHelper accountingHelper)
            : base(validator, accountingRepository)
        {
            NullGuard.NotNull(accountingHelper, nameof(accountingHelper));

            _accountingHelper = accountingHelper;
        }
示例#2
0
        public GetAccountingCollectionQueryHandler(IAccountingRepository accountingRepository, IAccountingHelper accountingHelper)
        {
            NullGuard.NotNull(accountingRepository, nameof(accountingRepository))
            .NotNull(accountingHelper, nameof(accountingHelper));

            _accountingRepository = accountingRepository;
            _accountingHelper     = accountingHelper;
        }
示例#3
0
        public void ApplyLogicForPrincipal_WhenAccountingCollectionIsNull_ThrowsArgumentNullException()
        {
            IAccountingHelper sut = CreateSut();

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ApplyLogicForPrincipal((IEnumerable <IAccounting>)null));

            Assert.That(result.ParamName, Is.EqualTo("accountingCollection"));
        }
示例#4
0
        public void ApplyLogicForPrincipal_WhenCalledWithAccountingCollection_AssertGetAccountingNumberWasCalledOnClaimResolver()
        {
            IAccountingHelper sut = CreateSut();

            sut.ApplyLogicForPrincipal(_fixture.CreateMany <IAccounting>(_random.Next(5, 10)).ToList());

            _claimResolverMock.Verify(m => m.GetAccountingNumber(), Times.Once);
        }
示例#5
0
        public void ApplyLogicForPrincipal_WhenCalledWithAccounting_AssertGetAccountingNumberWasCalledOnClaimResolver()
        {
            IAccountingHelper sut = CreateSut();

            sut.ApplyLogicForPrincipal(_fixture.Create <IAccounting>());

            _claimResolverMock.Verify(m => m.GetAccountingNumber(), Times.Once);
        }
示例#6
0
        public void ApplyLogicForPrincipal_WhenCalledWithAccounting_ReturnsAccounting()
        {
            IAccountingHelper sut = CreateSut();

            IAccounting accounting = _fixture.Create <IAccounting>();
            IAccounting result     = sut.ApplyLogicForPrincipal(accounting);

            Assert.That(result, Is.EqualTo(accounting));
        }
示例#7
0
        public void ApplyLogicForPrincipal_WhenCalledWithAccountingCollection_ReturnsAccountingCollection()
        {
            IAccountingHelper sut = CreateSut();

            IEnumerable <IAccounting> accountingCollection = _fixture.CreateMany <IAccounting>(_random.Next(5, 10)).ToList();
            IEnumerable <IAccounting> result = sut.ApplyLogicForPrincipal(accountingCollection);

            Assert.That(result, Is.EqualTo(accountingCollection));
        }
示例#8
0
        public void ApplyLogicForPrincipal_WhenCalledWithAccounting_AssertApplyDefaultForPrincipalWasCalledOnAccounting()
        {
            int accountingNumber  = _fixture.Create <int>();
            IAccountingHelper sut = CreateSut(accountingNumber);

            Mock <IAccounting> accountingMock = _fixture.BuildAccountingMock();

            sut.ApplyLogicForPrincipal(accountingMock.Object);

            accountingMock.Verify(m => m.ApplyDefaultForPrincipal(It.Is <int?>(value => value == accountingNumber)), Times.Once());
        }
示例#9
0
        public void ApplyLogicForPrincipal_WhenCalledWithAccountingCollection_AssertApplyDefaultForPrincipalWasCalledOnEachAccounting()
        {
            int accountingNumber  = _fixture.Create <int>();
            IAccountingHelper sut = CreateSut(accountingNumber);

            IEnumerable <Mock <IAccounting> > accountingMockCollection = new List <Mock <IAccounting> >
            {
                _fixture.BuildAccountingMock(),
                                              _fixture.BuildAccountingMock(),
                                              _fixture.BuildAccountingMock()
            };

            sut.ApplyLogicForPrincipal(accountingMockCollection.Select(accountingMock => accountingMock.Object).ToList());

            foreach (Mock <IAccounting> accountingMock in accountingMockCollection)
            {
                accountingMock.Verify(m => m.ApplyDefaultForPrincipal(It.Is <int?>(value => value == accountingNumber)), Times.Once());
            }
        }