public void ApplyLogicForPrincipal_WhenCalledWithAccounting_AssertGetAccountingNumberWasCalledOnClaimResolver() { IAccountingHelper sut = CreateSut(); sut.ApplyLogicForPrincipal(_fixture.Create <IAccounting>()); _claimResolverMock.Verify(m => m.GetAccountingNumber(), Times.Once); }
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); }
public void ApplyLogicForPrincipal_WhenCalledWithAccounting_ReturnsAccounting() { IAccountingHelper sut = CreateSut(); IAccounting accounting = _fixture.Create <IAccounting>(); IAccounting result = sut.ApplyLogicForPrincipal(accounting); Assert.That(result, Is.EqualTo(accounting)); }
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)); }
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()); }
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)); }
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); }
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()); } }
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")); }