public async Task QueryAsync_WhenCalled_AssertGetColumnNamesAsyncWasCalledOnContactToCsvConverter() { QueryHandler sut = CreateSut(); await sut.QueryAsync(CreateExportContactCollectionQuery()); _contactToCsvConverterMock.Verify(m => m.GetColumnNamesAsync(), Times.Once); }
public async Task QueryAsync_WhenCalled_ReturnNonEmptyByteArray() { QueryHandler sut = CreateSut(); byte[] result = await sut.QueryAsync(CreateExportContactCollectionQuery()); Assert.That(result.Length, Is.GreaterThan(0)); }
public async Task QueryAsync_WhenCalled_AssertToGetContactCollectionQueryWasCalledOnQuery() { QueryHandler sut = CreateSut(); Mock <IExportContactCollectionQuery> queryMock = CreateExportContactCollectionQueryMock(); await sut.QueryAsync(queryMock.Object); queryMock.Verify(m => m.ToGetContactCollectionQuery(), Times.Once); }
public async Task QueryAsync_WhenCalled_AssertQueryAsyncWasCalledOnGetContactCollectionQueryHandler() { QueryHandler sut = CreateSut(); IGetContactCollectionQuery getContactCollectionQuery = CreateGetContactCollectionQuery(); IExportContactCollectionQuery query = CreateExportContactCollectionQuery(getContactCollectionQuery); await sut.QueryAsync(query); _getContactCollectionQueryHandlerMock.Verify(m => m.QueryAsync(It.Is <IGetContactCollectionQuery>(value => value != null && value == getContactCollectionQuery)), Times.Once); }
public async Task QueryAsync_WhenCalled_AssertConvertAsyncWasCalledOnContactToCsvConverterForEachContactToExport() { IList <IContact> contactCollection = _fixture.CreateMany <IContact>(_random.Next(25, 50)).ToList(); QueryHandler sut = CreateSut(contactCollection); await sut.QueryAsync(CreateExportContactCollectionQuery()); foreach (IContact contact in contactCollection) { _contactToCsvConverterMock.Verify(m => m.ConvertAsync(It.Is <IContact>(value => value != null && value == contact)), 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")); }