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

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

            _claimResolverMock.Verify(m => m.GetAccountingNumber(), Times.Once);
        }
コード例 #2
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);
        }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
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());
        }
コード例 #6
0
        public async Task <IEnumerable <IAccounting> > QueryAsync(EmptyQuery query)
        {
            NullGuard.NotNull(query, nameof(query));

            IEnumerable <IAccounting> accountings = await _accountingRepository.GetAccountingsAsync();

            if (accountings == null)
            {
                return(new List <IAccounting>(0));
            }

            IEnumerable <IAccounting> calculatedAccountings = await Task.WhenAll(accountings.Select(accounting => accounting.CalculateAsync(DateTime.Today)).ToArray());

            return(_accountingHelper.ApplyLogicForPrincipal(calculatedAccountings));
        }
コード例 #7
0
        protected override async Task <IAccounting> GetDataAsync(IGetAccountingQuery query)
        {
            NullGuard.NotNull(query, nameof(query));

            IAccounting accounting = await AccountingRepository.GetAccountingAsync(query.AccountingNumber, query.StatusDate);

            if (accounting == null)
            {
                return(null);
            }

            _accountingHelper.ApplyLogicForPrincipal(accounting);

            return(accounting);
        }
コード例 #8
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());
            }
        }
コード例 #9
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"));
        }