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_WhenCalledAndContactCollectionWasNotReturnedFromMicrosoftGraphRepository_AssertApplyContactSupplementAsyncWasNotCalledOnContactRepository() { QueryHandler sut = CreateSut(false); IGetContactCollectionQuery query = CreateGetContactCollectionQueryMock().Object; await sut.QueryAsync(query); _contactRepositoryMock.Verify(m => m.ApplyContactSupplementAsync(It.IsAny <IEnumerable <IContact> >()), Times.Never); }
public async Task QueryAsync_WhenCalledAndContactCollectionWasReturnedFromMicrosoftGraphRepository_AssertApplyContactSupplementAsyncWasCalledOnContactRepositoryWithContactCollectionFromMicrosoftGraphRepository() { IEnumerable <IContact> microsoftGraphContactCollection = _fixture.CreateMany <IContact>(_random.Next(5, 15)).ToList(); QueryHandler sut = CreateSut(microsoftGraphContactCollection: microsoftGraphContactCollection); IGetContactCollectionQuery query = CreateGetContactCollectionQueryMock().Object; await sut.QueryAsync(query); _contactRepositoryMock.Verify(m => m.ApplyContactSupplementAsync(It.Is <IEnumerable <IContact> >(value => value.Equals(microsoftGraphContactCollection))), Times.Once); }
public async Task QueryAsync_WhenCalledAndContactCollectionWasNotReturnedFromMicrosoftGraphRepository_ReturnsEmptyContactCollection() { QueryHandler sut = CreateSut(false); IGetContactCollectionQuery query = CreateGetContactCollectionQueryMock().Object; IList <IContact> result = (await sut.QueryAsync(query)).ToList(); Assert.That(result, Is.Not.Null); Assert.That(result, Is.Empty); }
public async Task QueryAsync_WhenCalled_AssertGetContactsAsyncWasCalledOnMicrosoftGraphRepository() { QueryHandler sut = CreateSut(); IRefreshableToken token = _fixture.BuildRefreshableTokenMock().Object; IGetContactCollectionQuery query = CreateGetContactCollectionQueryMock(token).Object; await sut.QueryAsync(query); _microsoftGraphRepositoryMock.Verify(m => m.GetContactsAsync(It.Is <IRefreshableToken>(value => value == token)), Times.Once); }
public async Task QueryAsync_WhenCalledAndContactCollectionWasReturnedFromMicrosoftGraphRepository_ReturnsAppliedContactSupplementCollectionFromContactRepository() { IEnumerable <IContact> appliedContactSupplementCollection = _fixture.CreateMany <IContact>(_random.Next(5, 15)).ToList(); QueryHandler sut = CreateSut(appliedContactSupplementCollection: appliedContactSupplementCollection); IGetContactCollectionQuery query = CreateGetContactCollectionQueryMock().Object; IEnumerable <IContact> result = await sut.QueryAsync(query); Assert.That(result, Is.EqualTo(appliedContactSupplementCollection)); }