Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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"));
        }