Beispiel #1
0
        public async Task GetExistingContactAsync_WhenCalledAndNoContactWasReturnedFromMicrosoftGraphRepository_ReturnsNull()
        {
            IDeleteContactCommand sut = CreateSut(hasMicrosoftGraphContact: false);

            IContact result = await sut.GetExistingContactAsync(_microsoftGraphRepositoryMock.Object, _contactRepositoryMock.Object);

            Assert.That(result, Is.Null);
        }
Beispiel #2
0
        public async Task GetExistingContactAsync_WhenCalledAndNoContactWasReturnedFromMicrosoftGraphRepository_AssertApplyContactSupplementAsyncWasNotCalledOnContactRepository()
        {
            IDeleteContactCommand sut = CreateSut(hasMicrosoftGraphContact: false);

            await sut.GetExistingContactAsync(_microsoftGraphRepositoryMock.Object, _contactRepositoryMock.Object);

            _contactRepositoryMock.Verify(m => m.ApplyContactSupplementAsync(It.IsAny <IContact>()), Times.Never);
        }
Beispiel #3
0
        public async Task GetExistingContactAsync_WhenCalledAndContactWasReturnedFromMicrosoftGraphRepository_AssertApplyContactSupplementAsyncWasCalledOnContactRepositoryWithContactFromMicrosoftGraphRepository()
        {
            IContact microsoftGraphContact = _fixture.BuildContactMock().Object;
            IDeleteContactCommand sut      = CreateSut(microsoftGraphContact: microsoftGraphContact);

            await sut.GetExistingContactAsync(_microsoftGraphRepositoryMock.Object, _contactRepositoryMock.Object);

            _contactRepositoryMock.Verify(m => m.ApplyContactSupplementAsync(It.Is <IContact>(value => value == microsoftGraphContact)), Times.Once);
        }
Beispiel #4
0
        public async Task GetExistingContactAsync_WhenCalledAndContactWasReturnedFromMicrosoftGraphRepository_ReturnAppliedContactSupplementFromContactRepository()
        {
            IContact appliedContactSupplement = _fixture.BuildContactMock().Object;
            IDeleteContactCommand sut         = CreateSut(appliedContactSupplement: appliedContactSupplement);

            IContact result = await sut.GetExistingContactAsync(_microsoftGraphRepositoryMock.Object, _contactRepositoryMock.Object);

            Assert.That(result, Is.EqualTo(appliedContactSupplement));
        }
Beispiel #5
0
        public async Task GetExistingContactAsync_WhenCalled_AssertGetContactAsyncWasCalledOnMicrosoftGraphRepository()
        {
            string   tokenType          = _fixture.Create <string>();
            string   accessToken        = _fixture.Create <string>();
            DateTime expires            = _fixture.Create <DateTime>();
            string   refreshToken       = _fixture.Create <string>();
            string   externalIdentifier = _fixture.Create <string>();
            IDeleteContactCommand sut   = CreateSut(tokenType, accessToken, expires, refreshToken, externalIdentifier);

            await sut.GetExistingContactAsync(_microsoftGraphRepositoryMock.Object, _contactRepositoryMock.Object);

            _microsoftGraphRepositoryMock.Verify(m => m.GetContactAsync(
                                                     It.Is <IRefreshableToken>(value => value != null && string.CompareOrdinal(value.TokenType, tokenType) == 0 && string.CompareOrdinal(value.AccessToken, accessToken) == 0 && value.Expires == expires && string.CompareOrdinal(value.RefreshToken, refreshToken) == 0),
                                                     It.Is <string>(value => string.CompareOrdinal(value, externalIdentifier) == 0)),
                                                 Times.Once);
        }
Beispiel #6
0
        public void GetExistingContactAsync_WhenContactRepositoryIsNull_ThrowsArgumentNullException()
        {
            IDeleteContactCommand sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.GetExistingContactAsync(_microsoftGraphRepositoryMock.Object, null));

            Assert.That(result.ParamName, Is.EqualTo("contactRepository"));
        }