public void TestNoTokenInContext()
        {
            TokenContext context = new TokenContext();

            TokenResponseBuilder builder = new TokenResponseBuilder();

            TokenResponse response = builder.CreateResponse(context);
        }
        public void TestInvalidGrantContext()
        {
            TokenContext context = new TokenContext
            {
                Error = new ErrorResponse
                {
                    Error = Parameters.ErrorParameters.ErrorValues.InvalidGrant
                }
            };

            TokenResponseBuilder builder = new TokenResponseBuilder();

            TokenResponse response = builder.CreateResponse(context);

            Assert.AreEqual(400, response.HttpStatusCode);
            Assert.AreEqual("{\"error\":\"invalid_grant\"}", response.Body);
        }
        public void TestInvalidClientContext()
        {
            TokenContext context = new TokenContext
            {
                Error = new ErrorResponse
                {
                    Error            = Parameters.ErrorParameters.ErrorValues.InvalidClient,
                    ErrorDescription = string.Empty
                }
            };

            TokenResponseBuilder builder = new TokenResponseBuilder();

            TokenResponse response = builder.CreateResponse(context);

            Assert.AreEqual(401, response.HttpStatusCode);
            Assert.AreEqual("{\"error\":\"invalid_client\"}", response.Body);
        }
        public void TestValidClientContext()
        {
            TokenContext context = new TokenContext
            {
                Token = new AccessTokenBase
                {
                    ExpiresIn    = 3600,
                    Token        = "token",
                    RefreshToken = "refresh",
                    TokenType    = "bearer"
                }
            };

            TokenResponseBuilder builder = new TokenResponseBuilder();

            TokenResponse response = builder.CreateResponse(context);

            Assert.AreEqual(200, response.HttpStatusCode);
            Assert.AreEqual("{\"access_token\":\"token\",\"expires_in\":3600,\"refresh_token\":\"refresh\",\"token_type\":\"bearer\"}", response.Body);
        }