Exemple #1
0
        public async Task DeleteContact_WhenExternalIdentifierIsNotEmptyNullOrWhiteSpaceAndTokenWasReturnedFromTokenHelperFactory_ReturnsRedirectToActionResultWhereRouteValuesIsNull()
        {
            Controller sut = CreateSut();

            RedirectToActionResult result = (RedirectToActionResult)await sut.DeleteContact(_fixture.Create <string>());

            Assert.That(result.RouteValues, Is.Null);
        }
Exemple #2
0
        public async Task DeleteContact_WhenExternalIdentifierIsNotEmptyNullOrWhiteSpaceAndNoTokenWasReturnedFromTokenHelperFactory_AssertPublishAsyncWasNotCalledOnCommandBus()
        {
            Controller sut = CreateSut(false);

            await sut.DeleteContact(_fixture.Create <string>());

            _commandBusMock.Verify(m => m.PublishAsync(It.IsAny <IDeleteContactCommand>()), Times.Never);
        }
Exemple #3
0
        public async Task DeleteContact_WhenExternalIdentifierIsNotEmptyNullOrWhiteSpaceAndTokenWasReturnedFromTokenHelperFactory_ReturnsRedirectToActionResultWhereActionNameIsEqualToContacts()
        {
            Controller sut = CreateSut();

            RedirectToActionResult result = (RedirectToActionResult)await sut.DeleteContact(_fixture.Create <string>());

            Assert.That(result.ActionName, Is.EqualTo("Contacts"));
        }
Exemple #4
0
        public async Task DeleteContact_WhenExternalIdentifierIsNotEmptyNullOrWhiteSpaceAndTokenWasReturnedFromTokenHelperFactory_ReturnsRedirectToActionResult()
        {
            Controller sut = CreateSut();

            IActionResult result = await sut.DeleteContact(_fixture.Create <string>());

            Assert.That(result, Is.TypeOf <RedirectToActionResult>());
        }
Exemple #5
0
        public async Task DeleteContact_WhenExternalIdentifierIsNotEmptyNullOrWhiteSpace_AssertGetTokenAsyncWasCalledOnTokenHelperFactory()
        {
            Controller sut = CreateSut();

            await sut.DeleteContact(_fixture.Create <string>());

            _tokenHelperFactoryMock.Verify(m => m.GetTokenAsync <IRefreshableToken>(
                                               It.Is <TokenType>(value => value == TokenType.MicrosoftGraphToken),
                                               It.IsAny <HttpContext>()),
                                           Times.Once);
        }
Exemple #6
0
        public async Task DeleteContact_WhenExternalIdentifierIsNotEmptyNullOrWhiteSpaceAndTokenWasReturnedFromTokenHelperFactory_AssertPublishAsyncWasCalledOnCommandBus()
        {
            string            tokenType        = _fixture.Create <string>();
            string            accessToken      = _fixture.Create <string>();
            string            refreshToken     = _fixture.Create <string>();
            DateTime          expires          = DateTime.Now.AddSeconds(_random.Next(60, 300));
            IRefreshableToken refreshableToken = _fixture.BuildRefreshableTokenMock(tokenType, accessToken, refreshToken, expires).Object;
            Controller        sut = CreateSut(refreshableToken: refreshableToken);

            string externalIdentifier = _fixture.Create <string>();
            await sut.DeleteContact(externalIdentifier);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IDeleteContactCommand>(command =>
                                                                                     string.CompareOrdinal(command.TokenType, tokenType) == 0 &&
                                                                                     string.CompareOrdinal(command.AccessToken, accessToken) == 0 &&
                                                                                     string.CompareOrdinal(command.RefreshToken, refreshToken) == 0 &&
                                                                                     command.Expires == expires &&
                                                                                     string.CompareOrdinal(command.ExternalIdentifier, externalIdentifier) == 0)),
                                   Times.Once);
        }
Exemple #7
0
        public void DeleteContact_WhenExternalIdentifierIsWhiteSpace_ThrowsArgumentNullException()
        {
            Controller sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.DeleteContact(" "));

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