public async Task QueryAsync_WhenNoBudgetAccountCollectionWasReturnedFromAccountingRepository_ReturnsNotNull() { QueryHandler sut = CreateSut(false); IGetBudgetAccountCollectionQuery query = CreateQuery(); IBudgetAccountCollection result = await sut.QueryAsync(query); Assert.That(result, Is.Not.Null); }
public async Task QueryAsync_WhenCalled_AssertStatusDateWasCalledOnGetBudgetAccountCollectionQuery() { QueryHandler sut = CreateSut(); Mock<IGetBudgetAccountCollectionQuery> queryMock = CreateQueryMock(); await sut.QueryAsync(queryMock.Object); queryMock.Verify(m => m.StatusDate, Times.Exactly(2)); }
public async Task QueryAsync_WhenCalled_AssertAccountingNumberWasCalledOnGetBudgetAccountCollectionQuery() { QueryHandler sut = CreateSut(); Mock<IGetBudgetAccountCollectionQuery> queryMock = CreateQueryMock(); await sut.QueryAsync(queryMock.Object); queryMock.Verify(m => m.AccountingNumber, Times.Once); }
public async Task QueryAsync_WhenNoBudgetAccountCollectionWasReturnedFromAccountingRepository_ReturnsEmptyBudgetAccountCollection() { QueryHandler sut = CreateSut(false); IGetBudgetAccountCollectionQuery query = CreateQuery(); IBudgetAccountCollection result = await sut.QueryAsync(query); Assert.That(result.Count(), Is.EqualTo(0)); }
public async Task QueryAsync_WhenNoBudgetAccountCollectionWasReturnedFromAccountingRepository_ReturnsBudgetAccountCollectionWhereStatusDateIsEqualToStatusDateFromGetBudgetAccountCollectionQuery() { QueryHandler sut = CreateSut(false); DateTime statusDate = _fixture.Create<DateTime>().Date; IGetBudgetAccountCollectionQuery query = CreateQuery(statusDate: statusDate); IBudgetAccountCollection result = await sut.QueryAsync(query); Assert.That(result.StatusDate, Is.EqualTo(statusDate)); }
public async Task QueryAsync_WhenBudgetAccountCollectionWasReturnedFromAccountingRepository_ReturnsCalculatedBudgetAccountCollection() { IBudgetAccountCollection calculatedBudgetAccountCollection = _fixture.BuildBudgetAccountCollectionMock().Object; IBudgetAccountCollection budgetAccountCollection = _fixture.BuildBudgetAccountCollectionMock(calculatedBudgetAccountCollection: calculatedBudgetAccountCollection).Object; QueryHandler sut = CreateSut(budgetAccountCollection: budgetAccountCollection); IGetBudgetAccountCollectionQuery query = CreateQuery(); IBudgetAccountCollection result = await sut.QueryAsync(query); Assert.That(result, Is.EqualTo(calculatedBudgetAccountCollection)); }
public async Task QueryAsync_WhenCalled_AssertGetBudgetAccountsAsyncWasCalledOnAccountingRepository() { QueryHandler sut = CreateSut(); int accountingNumber = _fixture.Create<int>(); DateTime statusDate = _fixture.Create<DateTime>().Date; IGetBudgetAccountCollectionQuery query = CreateQuery(accountingNumber, statusDate); await sut.QueryAsync(query); _accountingRepositoryMock.Verify(m => m.GetBudgetAccountsAsync( 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")); }