public async Task QueryAsync_WhenNoContactAccountCollectionWasReturnedFromAccountingRepository_ReturnsNotNull()
        {
            QueryHandler sut = CreateSut(false);

            IGetContactAccountCollectionQuery query  = CreateQuery();
            IContactAccountCollection         result = await sut.QueryAsync(query);

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

            Mock <IGetContactAccountCollectionQuery> queryMock = CreateQueryMock();
            await sut.QueryAsync(queryMock.Object);

            queryMock.Verify(m => m.StatusDate, Times.Exactly(2));
        }
        public async Task QueryAsync_WhenCalled_AssertAccountingNumberWasCalledOnGetContactAccountCollectionQuery()
        {
            QueryHandler sut = CreateSut();

            Mock <IGetContactAccountCollectionQuery> queryMock = CreateQueryMock();
            await sut.QueryAsync(queryMock.Object);

            queryMock.Verify(m => m.AccountingNumber, Times.Once);
        }
        public async Task QueryAsync_WhenNoContactAccountCollectionWasReturnedFromAccountingRepository_ReturnsEmptyContactAccountCollection()
        {
            QueryHandler sut = CreateSut(false);

            IGetContactAccountCollectionQuery query  = CreateQuery();
            IContactAccountCollection         result = await sut.QueryAsync(query);

            Assert.That(result.Count(), Is.EqualTo(0));
        }
        public async Task QueryAsync_WhenNoContactAccountCollectionWasReturnedFromAccountingRepository_ReturnsContactAccountCollectionWhereStatusDateIsEqualToStatusDateFromGetContactAccountCollectionQuery()
        {
            QueryHandler sut = CreateSut(false);

            DateTime statusDate = _fixture.Create <DateTime>().Date;
            IGetContactAccountCollectionQuery query  = CreateQuery(statusDate: statusDate);
            IContactAccountCollection         result = await sut.QueryAsync(query);

            Assert.That(result.StatusDate, Is.EqualTo(statusDate));
        }
        public async Task QueryAsync_WhenContactAccountCollectionWasReturnedFromAccountingRepository_ReturnsCalculatedContactAccountCollection()
        {
            IContactAccountCollection calculatedContactAccountCollection = _fixture.BuildContactAccountCollectionMock().Object;
            IContactAccountCollection contactAccountCollection           = _fixture.BuildContactAccountCollectionMock(calculatedContactAccountCollection: calculatedContactAccountCollection).Object;
            QueryHandler sut = CreateSut(contactAccountCollection: contactAccountCollection);

            IGetContactAccountCollectionQuery query  = CreateQuery();
            IContactAccountCollection         result = await sut.QueryAsync(query);

            Assert.That(result, Is.EqualTo(calculatedContactAccountCollection));
        }
        public async Task QueryAsync_WhenCalled_AssertGetContactAccountsAsyncWasCalledOnAccountingRepository()
        {
            QueryHandler sut = CreateSut();

            int      accountingNumber = _fixture.Create <int>();
            DateTime statusDate       = _fixture.Create <DateTime>().Date;
            IGetContactAccountCollectionQuery query = CreateQuery(accountingNumber, statusDate);
            await sut.QueryAsync(query);

            _accountingRepositoryMock.Verify(m => m.GetContactAccountsAsync(
                                                 It.Is <int>(value => value == accountingNumber),
                                                 It.Is <DateTime>(value => value == statusDate)),
                                             Times.Once);
        }
        public void QueryAsync_WhenQueryIsNull_ThrowsArgumentNullException()
        {
            QueryHandler sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.QueryAsync(null));

            Assert.That(result.ParamName, Is.EqualTo("query"));
        }