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_WhenCalledAndNoContactWasReturnedFromMicrosoftGraphRepository_ReturnsNull() { QueryHandler sut = CreateSut(hasMicrosoftGraphContact: false); IGetContactQuery query = CreateGetContactQueryMock().Object; IContact result = await sut.QueryAsync(query); Assert.That(result, Is.Null); }
public async Task QueryAsync_WhenCalledAndNoContactWasReturnedFromMicrosoftGraphRepository_AssertApplyContactSupplementAsyncWasNotCalledOnContactRepository() { QueryHandler sut = CreateSut(hasMicrosoftGraphContact: false); IGetContactQuery query = CreateGetContactQueryMock().Object; await sut.QueryAsync(query); _contactRepositoryMock.Verify(m => m.ApplyContactSupplementAsync(It.IsAny <IContact>()), Times.Never); }
public async Task QueryAsync_WhenCalledAndContactWasReturnedFromMicrosoftGraphRepository_AssertApplyContactSupplementAsyncWasCalledOnContactRepositoryWithContactFromMicrosoftGraphRepository() { IContact microsoftGraphContact = _fixture.BuildContactMock().Object; QueryHandler sut = CreateSut(microsoftGraphContact: microsoftGraphContact); IGetContactQuery query = CreateGetContactQueryMock().Object; await sut.QueryAsync(query); _contactRepositoryMock.Verify(m => m.ApplyContactSupplementAsync(It.Is <IContact>(value => value == microsoftGraphContact)), Times.Once); }
public async Task QueryAsync_WhenCalledAndContactWasReturnedFromMicrosoftGraphRepository_ReturnsAppliedContactSupplementFromContactRepository() { IContact appliedContactSupplement = _fixture.BuildContactMock().Object; QueryHandler sut = CreateSut(appliedContactSupplement: appliedContactSupplement); IGetContactQuery query = CreateGetContactQueryMock().Object; IContact result = await sut.QueryAsync(query); Assert.That(result, Is.EqualTo(appliedContactSupplement)); }
public async Task QueryAsync_WhenCalled_AssertGetContactAsyncWasCalledOnMicrosoftGraphRepository() { QueryHandler sut = CreateSut(); string externalIdentifier = _fixture.Create <string>(); IRefreshableToken token = _fixture.BuildRefreshableTokenMock().Object; IGetContactQuery query = CreateGetContactQueryMock(externalIdentifier, token).Object; await sut.QueryAsync(query); _microsoftGraphRepositoryMock.Verify(m => m.GetContactAsync( It.Is <IRefreshableToken>(value => value == token), It.Is <string>(value => string.CompareOrdinal(value, externalIdentifier) == 0)), Times.Once); }