DbTable支持ToJson,单元测试通过
大石头 authored at 2020-02-02 19:17:36
895.00 B
X
using System;
using System.Collections.Generic;
using System.Text;
using NewLife.Data;
using Xunit;

namespace XUnitTest.Data
{
    public class DbTableTests
    {
        //[Fact]
        //public void ToJson()
        //{

        //}

        [Fact]
        public void ToDictionary()
        {
            var db = new DbTable
            {
                Columns = new[] { "Id", "Name", "CreateTime" },
                Rows = new List<Object[]>
                {
                    new Object[] { 123, "Stone", DateTime.Now },
                    new Object[] { 456, "NewLife", DateTime.Today }
                }
            };

            var list = db.ToDictionary();
            Assert.NotNull(list);
            Assert.Equal(2, list.Count);

            var dic = list[0];
            Assert.Equal(123, dic["Id"]);
            Assert.Equal("Stone", dic["Name"]);
        }
    }
}