public async Task QueryAsync_WhenCalled_AssertStatusDateWasCalledOnGetAccountQuery()
        {
            QueryHandler sut = CreateSut();

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

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

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

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

            IGetAccountQuery query  = CreateQuery();
            IAccount         result = await sut.QueryAsync(query);

            Assert.That(result, Is.Null);
        }
        public async Task QueryAsync_WhenAccountWasReturnedFromAccountingRepository_ReturnsCalculatedAccount()
        {
            IAccount     calculatedAccount = _fixture.BuildAccountMock().Object;
            IAccount     account           = _fixture.BuildAccountMock(calculatedAccount: calculatedAccount).Object;
            QueryHandler sut = CreateSut(account: account);

            IGetAccountQuery query  = CreateQuery();
            IAccount         result = await sut.QueryAsync(query);

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

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

            _accountingRepositoryMock.Verify(m => m.GetAccountAsync(
                                                 It.Is <int>(value => value == accountingNumber),
                                                 It.Is <string>(value => string.CompareOrdinal(value, accountNumber) == 0),
                                                 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"));
        }