public async Task AccountsAsync_WhenCalled_ReturnsNotNull()
        {
            Controller sut = CreateSut();

            ActionResult <AccountCollectionModel> result = await sut.AccountsAsync(_fixture.Create <int>());

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

            ActionResult <AccountCollectionModel> result = await sut.AccountsAsync(_fixture.Create <int>());

            Assert.That(result.Result, Is.TypeOf <OkObjectResult>());
        }
        public async Task AccountsAsync_WhenCalled_ReturnsOkObjectResultWhereValueIsAccountCollectionModel()
        {
            Controller sut = CreateSut();

            OkObjectResult result = (OkObjectResult)(await sut.AccountsAsync(_fixture.Create <int>())).Result;

            Assert.That(result.Value, Is.TypeOf <AccountCollectionModel>());
        }
        public async Task AccountsAsync_WhenCalled_ReturnsOkObjectResultWhereValueIsNotNull()
        {
            Controller sut = CreateSut();

            OkObjectResult result = (OkObjectResult)(await sut.AccountsAsync(_fixture.Create <int>())).Result;

            Assert.That(result.Value, Is.Not.Null);
        }
        public async Task AccountsAsync_WhenCalledWithoutStatusDate_AssertQueryAsyncWasCalledOnQueryBus()
        {
            Controller sut = CreateSut();

            int accountingNumber = _fixture.Create <int>();
            await sut.AccountsAsync(accountingNumber);

            _queryBusMock.Verify(m => m.QueryAsync <IGetAccountCollectionQuery, IAccountCollection>(It.Is <IGetAccountCollectionQuery>(value => value.AccountingNumber == accountingNumber && value.StatusDate == DateTime.Today)), Times.Once);
        }
        public async Task AccountsAsync_WhenCalledWithStatusDate_AssertQueryAsyncWasCalledOnQueryBus()
        {
            Controller sut = CreateSut();

            int      accountingNumber = _fixture.Create <int>();
            DateTime statusDate       = DateTime.Now.AddDays(_random.Next(1, 365) * -1);
            await sut.AccountsAsync(accountingNumber, statusDate);

            _queryBusMock.Verify(m => m.QueryAsync <IGetAccountCollectionQuery, IAccountCollection>(It.Is <IGetAccountCollectionQuery>(value => value.AccountingNumber == accountingNumber && value.StatusDate == statusDate.Date)), Times.Once);
        }
        public async Task AccountsAsync_WhenCalled_ReturnsOkObjectResultWhereValueIsAccountCollectionModelContainingAllAccounts()
        {
            IList <IAccount>   accounts          = _fixture.CreateMany <IAccount>(_random.Next(5, 10)).ToList();
            IAccountCollection accountCollection = _fixture.BuildAccountCollectionMock(accountCollection: accounts).Object;
            Controller         sut = CreateSut(accountCollection);

            OkObjectResult result = (OkObjectResult)(await sut.AccountsAsync(_fixture.Create <int>())).Result;

            AccountCollectionModel accountCollectionModel = (AccountCollectionModel)result.Value;

            Assert.That(accountCollectionModel, Is.Not.Null);
            Assert.That(accountCollectionModel.Count, Is.EqualTo(accounts.Count));
            Assert.That(accountCollectionModel.All(accountModel => accounts.SingleOrDefault(account => string.CompareOrdinal(accountModel.AccountNumber, account.AccountNumber) == 0) != null), Is.True);
        }