public void Handle_GivenSuccessfulUseCaseResponse_SetsRefreshToken()
    {
        // arrange
        const string token     = "777888AAABBB";
        var          presenter = new ExchangeRefreshTokenPresenter();

        // act
        presenter.Handle(new Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse(null, token, true));

        // assert
        Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse data = JsonSerializer.DeSerializeObject <Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse>(presenter.ContentResult.Content);
        Assert.Equal(token, data.RefreshToken);
    }
예제 #2
0
        public void Handle_GivenFailedUseCaseResponse_SetsError()
        {
            // arrange
            var presenter = new ExchangeRefreshTokenPresenter();

            // act
            presenter.Handle(new ExchangeRefreshTokenResponse(false, "Invalid Token."));

            // assert
            var data = JsonConvert.DeserializeObject(presenter.ContentResult.Content);

            Assert.Equal((int)HttpStatusCode.BadRequest, presenter.ContentResult.StatusCode);
            Assert.Equal("Invalid Token.", data);
        }
예제 #3
0
        public void Handle_GivenSuccessfulUseCaseResponse_SetsRefreshToken()
        {
            // arrange
            const string token     = "777888AAABBB";
            var          presenter = new ExchangeRefreshTokenPresenter();

            // act
            presenter.Handle(new ExchangeRefreshTokenResponse(null, token, true));

            // assert
            dynamic data = JsonConvert.DeserializeObject(presenter.ContentResult.Content);

            Assert.Equal(token, data.refreshToken.Value);
        }
    public void Handle_GivenSuccessfulUseCaseResponse_SetsAccessToken()
    {
        // arrange
        const string token     = "777888AAABBB";
        var          presenter = new ExchangeRefreshTokenPresenter();

        // act
        presenter.Handle(new Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse(new AccessToken(token, 0), "", true));

        // assert
        Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse data = JsonSerializer.DeSerializeObject <Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse>(presenter.ContentResult.Content);
        Assert.NotNull(data);
        Assert.NotNull(data.AccessToken);
        Assert.False(string.IsNullOrEmpty(data.AccessToken.Token));
        Assert.Equal(token, data.AccessToken.Token);
    }
예제 #5
0
    public void Handle_GivenSuccessfulUseCaseResponse_SetsRefreshToken()
    {
        // arrange
        const string token     = "777888AAABBB";
        var          presenter = new ExchangeRefreshTokenPresenter(_mapper);

        // act
        presenter.Handle(new Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse(null, token, true));

        // assert
        Assert.NotNull(presenter.Response);
        Assert.True(presenter.Response.Response.Success);
        Assert.False(presenter.Response.Response.Errors.Any());
        Assert.False(string.IsNullOrEmpty(presenter.Response.RefreshToken));
        Assert.Equal(token, presenter.Response.RefreshToken);
    }
예제 #6
0
    public void Handle_GivenFailedUseCaseResponse_SetsError()
    {
        // arrange
        var presenter = new ExchangeRefreshTokenPresenter(_mapper);

        // act
        presenter.Handle(new Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse(new List <Error>()
        {
            new Error(HttpStatusCode.BadRequest.ToString(), "Invalid Token!")
        }));

        // assert
        Assert.NotNull(presenter.Response);
        Assert.Null(presenter.Response.AccessToken);
        Assert.True(string.IsNullOrEmpty(presenter.Response.RefreshToken));
        Assert.NotNull(presenter.Response.Response.Errors);
        Assert.Single(presenter.Response.Response.Errors);
        Assert.Equal(HttpStatusCode.BadRequest.ToString(), presenter.Response.Response.Errors.First().Code);
        Assert.Equal("Invalid Token!", presenter.Response.Response.Errors.First().Description);
    }
    public void Handle_GivenFailedUseCaseResponse_SetsError()
    {
        // arrange
        var presenter = new ExchangeRefreshTokenPresenter();

        // act
        presenter.Handle(new Core.DTO.UseCaseResponses.ExchangeRefreshTokenResponse(new List <Error>()
        {
            new Error(HttpStatusCode.BadRequest.ToString(), "Invalid Token!")
        }));

        // assert
        Models.Response.ExchangeRefreshTokenResponse response = Serialization.JsonSerializer.DeSerializeObject <Models.Response.ExchangeRefreshTokenResponse>(presenter.ContentResult.Content);
        Assert.Equal((int)HttpStatusCode.BadRequest, presenter.ContentResult.StatusCode);
        Assert.NotNull(response);
        Assert.Null(response.AccessToken);
        Assert.True(string.IsNullOrEmpty(response.RefreshToken));
        Assert.NotNull(response.Errors);
        Assert.Single(response.Errors);
        Assert.Equal(HttpStatusCode.BadRequest.ToString(), response.Errors.First().Code);
        Assert.Equal("Invalid Token!", response.Errors.First().Description);
    }