public async Task FindCreditorsAsync_WhenContactAccountCollectionContainsCreditorContactAccounts_ReturnsAccountCollectionWithCreditorContactAccountsFromContactAccountCollection() { IContactAccountCollection sut = CreateSut(); IEnumerable <IContactAccount> creditorContactAccountCollection = new List <IContactAccount> { _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor).Object }; sut.Add(creditorContactAccountCollection); IEnumerable <IContactAccount> nonCreditorContactAccountCollection = new List <IContactAccount> { _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object }; sut.Add(nonCreditorContactAccountCollection); IContactAccountCollection result = await sut.FindCreditorsAsync(); Assert.That(result.Count(), Is.EqualTo(creditorContactAccountCollection.Count())); Assert.That(result.All(contactAccount => creditorContactAccountCollection.Contains(contactAccount)), Is.True); }
public void ValuesAtEndOfLastMonthFromStatusDate_WhenCalculateAsyncHasNotBeenCalled_ReturnsContactAccountCollectionValuesWhereCreditorsIsEqualToZero() { IContactAccountCollection sut = CreateSut(); sut.Add(_fixture.CreateMany <IContactAccount>(_random.Next(5, 10)).ToArray()); IContactAccountCollectionValues result = sut.ValuesAtEndOfLastMonthFromStatusDate; Assert.That(result.Creditors, Is.EqualTo(0M)); }
public void ValuesAtEndOfLastMonthFromStatusDate_WhenCalculateAsyncHasNotBeenCalled_ReturnsNotNull() { IContactAccountCollection sut = CreateSut(); sut.Add(_fixture.CreateMany <IContactAccount>(_random.Next(5, 10)).ToArray()); IContactAccountCollectionValues result = sut.ValuesAtEndOfLastMonthFromStatusDate; Assert.That(result, Is.Not.Null); }
public async Task FindDebtorsAsync_WhenContactAccountCollectionContainsOnlyNonDebtorContactAccounts_ReturnsEmptyAccountCollection() { IContactAccountCollection sut = CreateSut(); IEnumerable <IContactAccount> nonDebtorContactAccountCollection = new List <IContactAccount> { _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor).Object }; sut.Add(nonDebtorContactAccountCollection); IContactAccountCollection result = await sut.FindDebtorsAsync(); Assert.That(result.Count(), Is.EqualTo(0)); }
public async Task FindDebtorsAsync_WhenContactAccountCollectionContainsContactAccounts_ReturnsNotNull() { IContactAccountCollection sut = CreateSut(); IEnumerable <IContactAccount> contactAccountCollection = new List <IContactAccount> { _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object }; sut.Add(contactAccountCollection); IContactAccountCollection result = await sut.FindDebtorsAsync(); Assert.That(result, Is.Not.Null); }
public async Task FindDebtorsAsync_WhenContactAccountCollectionContainsContactAccounts_ReturnsCalculatedAccountCollection() { IContactAccountCollection sut = CreateSut(); IEnumerable <IContactAccount> contactAccountCollection = new List <IContactAccount> { _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object, _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor).Object }; sut.Add(contactAccountCollection); DateTime statusDate = DateTime.Now.AddDays(_random.Next(1, 365) * -1); IContactAccountCollection result = await(await sut.CalculateAsync(statusDate)).FindDebtorsAsync(); Assert.That(result.StatusDate, Is.EqualTo(statusDate.Date)); }
public async Task FindDebtorsAsync_WhenCalled_AssertContactAccountTypeWasCalledOnEachContactAccountInContactAccountCollection() { IContactAccountCollection sut = CreateSut(); IEnumerable <Mock <IContactAccount> > contactAccountMockCollection = new List <Mock <IContactAccount> > { _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor), _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor), _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor), _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor), _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor), _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor), _fixture.BuildContactAccountMock(contactAccountType: _random.Next(100) > 50 ? ContactAccountType.Debtor : ContactAccountType.Creditor) }; sut.Add(contactAccountMockCollection.Select(contactAccountMock => contactAccountMock.Object).ToArray()); await sut.FindDebtorsAsync(); foreach (Mock <IContactAccount> contactAccountMock in contactAccountMockCollection) { contactAccountMock.Verify(m => m.ContactAccountType, Times.Once); } }