public async Task FindDebtorsAsync_WhenCalled_AssertAccountNameWasNotCalledOnAnyNoneDebtorContactAccountInContactAccountCollection()
        {
            IContactAccountCollection sut = CreateSut();

            IEnumerable <IContactAccount> debtorContactAccountCollection = new List <IContactAccount>
            {
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object,
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object,
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object
            };

            sut.Add(debtorContactAccountCollection);

            IEnumerable <Mock <IContactAccount> > nonDebtorContactAccountMockCollection = new List <Mock <IContactAccount> >
            {
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Creditor)
            };

            sut.Add(nonDebtorContactAccountMockCollection.Select(nonDebtorContactAccountMock => nonDebtorContactAccountMock.Object).ToArray());

            await sut.FindDebtorsAsync();

            foreach (Mock <IContactAccount> nonDebtorContactAccountMock in nonDebtorContactAccountMockCollection)
            {
                nonDebtorContactAccountMock.Verify(m => m.AccountName, Times.Never);
            }
        }
        public async Task FindDebtorsAsync_WhenContactAccountCollectionContainsDebtorContactAccounts_ReturnsAccountCollectionWithDebtorContactAccountsFromContactAccountCollection()
        {
            IContactAccountCollection sut = CreateSut();

            IEnumerable <IContactAccount> debtorContactAccountCollection = new List <IContactAccount>
            {
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object,
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object,
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor).Object
            };

            sut.Add(debtorContactAccountCollection);

            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(debtorContactAccountCollection.Count()));
            Assert.That(result.All(contactAccount => debtorContactAccountCollection.Contains(contactAccount)), Is.True);
        }
        public async Task FindDebtorsAsync_WhenContactAccountCollectionIsEmpty_ReturnsNotNull()
        {
            IContactAccountCollection sut = CreateSut();

            IContactAccountCollection result = await sut.FindDebtorsAsync();

            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_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);
            }
        }