TokenModel由核心类库实现
智能石头 authored at 2021-03-16 13:33:27
905.00 B
Stardust
using System;
using System.Collections.Generic;
using System.Text;
using NewLife.Security;
using NewLife.Serialization;
using NewLife.Web;
using Stardust.Models;
using Xunit;

namespace ClientTest
{
    public class TokenModelTests
    {
        [Fact]
        public void Test1()
        {
            var model = new TokenModel
            {
                AccessToken = Rand.NextString(32),
                TokenType = "token",
                ExpireIn = 7200,
                RefreshToken = Rand.NextString(32),
            };

            var json = model.ToJson();

            var rs = "{\"access_token\":\"{access_token}\",\"token_type\":\"token\",\"expire_in\":7200,\"refresh_token\":\"{refresh_token}\"}";
            rs = rs.Replace("{access_token}", model.AccessToken)
                .Replace("{refresh_token}", model.RefreshToken);

            Assert.Equal(rs, json);
        }
    }
}