public async Task FindCreditorsAsync_WhenCalled_AssertAccountNameWasNotCalledOnAnyNoneCreditorContactAccountInContactAccountCollection()
        {
            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 <Mock <IContactAccount> > nonCreditorContactAccountMockCollection = new List <Mock <IContactAccount> >
            {
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.None),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor),
                _fixture.BuildContactAccountMock(contactAccountType: ContactAccountType.Debtor)
            };

            sut.Add(nonCreditorContactAccountMockCollection.Select(nonCreditorContactAccountMock => nonCreditorContactAccountMock.Object).ToArray());

            await sut.FindCreditorsAsync();

            foreach (Mock <IContactAccount> nonCreditorContactAccountMock in nonCreditorContactAccountMockCollection)
            {
                nonCreditorContactAccountMock.Verify(m => m.AccountName, Times.Never);
            }
        }
        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 async Task FindCreditorsAsync_WhenContactAccountCollectionIsEmpty_ReturnsNotNull()
        {
            IContactAccountCollection sut = CreateSut();

            IContactAccountCollection result = await sut.FindCreditorsAsync();

            Assert.That(result, Is.Not.Null);
        }
        public async Task FindCreditorsAsync_WhenContactAccountCollectionContainsOnlyNonCreditorContactAccounts_ReturnsEmptyAccountCollection()
        {
            IContactAccountCollection sut = CreateSut();

            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(0));
        }
        public async Task FindCreditorsAsync_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.FindCreditorsAsync();

            Assert.That(result, Is.Not.Null);
        }
        public async Task FindCreditorsAsync_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.FindCreditorsAsync();

            foreach (Mock <IContactAccount> contactAccountMock in contactAccountMockCollection)
            {
                contactAccountMock.Verify(m => m.ContactAccountType, Times.Once);
            }
        }