예제 #1
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"));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }