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")); }
public async Task QueryAsync_WhenCalled_AssertNumberWasCalledOnGetContactGroupQuery() { QueryHandler sut = CreateSut(); Mock <IGetContactGroupQuery> queryMock = CreateQueryMock(); await sut.QueryAsync(queryMock.Object); queryMock.Verify(m => m.Number, Times.Once); }
public async Task QueryAsync_WhenCalled_ReturnsContactGroupFromContactRepository() { IContactGroup contactGroup = _fixture.BuildContactGroupMock().Object; QueryHandler sut = CreateSut(contactGroup); IGetContactGroupQuery query = CreateQueryMock().Object; IContactGroup result = await sut.QueryAsync(query); Assert.That(result, Is.EqualTo(contactGroup)); }
public async Task QueryAsync_WhenCalled_AssertGetContactGroupAsyncWasCalledOnContactRepository() { QueryHandler sut = CreateSut(); int number = _fixture.Create <int>(); IGetContactGroupQuery query = CreateQueryMock(number).Object; await sut.QueryAsync(query); _contactRepositoryMock.Verify(m => m.GetContactGroupAsync(It.Is <int>(value => value == number)), Times.Once); }
public async Task QueryAsync_WhenCalled_AssertValidateWasCalledOnGetContactGroupQuery() { QueryHandler sut = CreateSut(); Mock <IGetContactGroupQuery> queryMock = CreateQueryMock(); await sut.QueryAsync(queryMock.Object); queryMock.Verify(m => m.Validate( It.Is <IValidator>(value => value == _validatorMock.Object), It.Is <IContactRepository>(value => value == _contactRepositoryMock.Object)), Times.Once); }