public async Task CalculateAsync_WhenCalled_ReturnsSameCalculable() { ICalculable <IAccounting> sut = CreateSut(); IAccounting result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1)); Assert.That(result, Is.SameAs(sut)); }
public async Task CalculateAsync_WhenCalledMultipleTimesWithSameStatusDate_ReturnsSameCalculable() { ICalculable <IAccounting> sut = CreateSut(); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); IAccounting result = await(await(await sut.CalculateAsync(statusDate)).CalculateAsync(statusDate)).CalculateAsync(statusDate); Assert.That(result, Is.SameAs(sut)); }
public async Task CalculateAsync_WhenCalled_ReturnsSameCalculableWhereStatusDateEqualDateFromCall() { ICalculable <IAccounting> sut = CreateSut(); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); IAccounting result = await sut.CalculateAsync(statusDate); Assert.That(result.StatusDate, Is.EqualTo(statusDate.Date)); }
public async Task CalculateAsync_WhenCalled_AssertCalculateAsyncWasCalledOnContactAccountCollection() { Mock <IContactAccountCollection> contactAccountCollectionMock = _fixture.BuildContactAccountCollectionMock(); ICalculable <IAccounting> sut = CreateSut(contactAccountCollection: contactAccountCollectionMock.Object); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); await sut.CalculateAsync(statusDate); contactAccountCollectionMock.Verify(m => m.CalculateAsync(It.Is <DateTime>(value => value == statusDate.Date)), Times.Once); }
public async Task CalculateAsync_WhenCalled_ReturnsSameCalculableWithCalculatedContactAccountCollection() { IContactAccountCollection calculatedContactAccountCollection = _fixture.BuildContactAccountCollectionMock().Object; IContactAccountCollection contactAccountCollection = _fixture.BuildContactAccountCollectionMock(calculatedContactAccountCollection: calculatedContactAccountCollection).Object; ICalculable <IAccounting> sut = CreateSut(contactAccountCollection: contactAccountCollection); IAccounting result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1)); Assert.That(result.ContactAccountCollection, Is.EqualTo(calculatedContactAccountCollection)); }
public async Task CalculateAsync_WhenCalledMultipleTimesWithSameStatusDate_AssertCalculateAsyncWasCalledOnlyOnceOnBudgetAccountCollection() { Mock <IBudgetAccountCollection> budgetAccountCollectionMock = _fixture.BuildBudgetAccountCollectionMock(); ICalculable <IAccounting> sut = CreateSut(budgetAccountCollection: budgetAccountCollectionMock.Object); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); await(await(await sut.CalculateAsync(statusDate)).CalculateAsync(statusDate)).CalculateAsync(statusDate); budgetAccountCollectionMock.Verify(m => m.CalculateAsync(It.Is <DateTime>(value => value == statusDate.Date)), Times.Once); }
public async Task CalculateAsync_WhenCalled_AssertApplyCalculationAsyncWasCalledOnEachPostingLineCollectionForEachAccountFromCalculatedAccountCollection() { IList <Mock <IPostingLineCollection> > postingLineCollectionMockCollection = new List <Mock <IPostingLineCollection> > { _fixture.BuildPostingLineCollectionMock(isEmpty: true), _fixture.BuildPostingLineCollectionMock(isEmpty: true), _fixture.BuildPostingLineCollectionMock(isEmpty: true), _fixture.BuildPostingLineCollectionMock(isEmpty: true), _fixture.BuildPostingLineCollectionMock(isEmpty: true), _fixture.BuildPostingLineCollectionMock(isEmpty: true), _fixture.BuildPostingLineCollectionMock(isEmpty: true) }; IAccountCollection calculatedAccountCollection = _fixture.BuildAccountCollectionMock(accountCollection: postingLineCollectionMockCollection.Select(m => _fixture.BuildAccountMock(postingLineCollection: m.Object).Object).ToArray()).Object; IAccountCollection accountCollection = _fixture.BuildAccountCollectionMock(calculatedAccountCollection: calculatedAccountCollection).Object; ICalculable <IAccounting> sut = CreateSut(accountCollection); await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1)); foreach (Mock <IPostingLineCollection> postingLineCollectionMock in postingLineCollectionMockCollection) { postingLineCollectionMock.Verify(m => m.ApplyCalculationAsync(It.Is <IAccounting>(value => value != null && value == sut)), Times.Once); } }
public async Task CalculateAsync_WhenCalled_AssertPostingLineCollectionWasCalledOnEachAccountFromCalculatedAccountCollection() { IList <Mock <IAccount> > accountMockCollection = new List <Mock <IAccount> > { _fixture.BuildAccountMock(), _fixture.BuildAccountMock(), _fixture.BuildAccountMock(), _fixture.BuildAccountMock(), _fixture.BuildAccountMock(), _fixture.BuildAccountMock(), _fixture.BuildAccountMock() }; IAccountCollection calculatedAccountCollection = _fixture.BuildAccountCollectionMock(accountCollection: accountMockCollection.Select(m => m.Object).ToArray()).Object; IAccountCollection accountCollection = _fixture.BuildAccountCollectionMock(calculatedAccountCollection: calculatedAccountCollection).Object; ICalculable <IAccounting> sut = CreateSut(accountCollection); await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1)); foreach (Mock <IAccount> accountMock in accountMockCollection) { accountMock.Verify(m => m.PostingLineCollection, Times.Once); } }