[fix]修正UdpServer在接收广播时连续启动接收的错误,在StarAgent中,此时可能收到广播包,SocketFlags是Broadcast,需要清空,否则报错“参考的对象类型不支持尝试的操作”; 无需设置SocketOptionName.PacketInformation,在ReceiveMessageFromAsync时会自动设置,并且支持ipv6;
石头 编写于 2024-10-10 00:36:00 石头 提交于 2024-10-10 00:45:43
X
using System;
using System.Linq;
using System.Text;
using NewLife.IO;
using Xunit;

namespace XUnitTest.IO
{
    public class ExcelReaderTests
    {
        [Fact]
        public void Test1()
        {
            var type = GetType();
            var stream = type.Assembly.GetManifestResourceStream(type.Namespace + ".excel.xlsx");
            Assert.NotNull(stream);

            var reader = new ExcelReader(stream, Encoding.UTF8);
            var rows = reader.ReadRows().ToList();
            Assert.Equal(927, rows.Count);

            var names = "序号,名字,昵称,启用,年龄,生日,时间,余额,比率".Split(",");
            var fields = rows[0].Cast<String>().ToArray();
            Assert.Equal(names.Length, fields.Length);
            for (var i = 0; i < names.Length; i++)
            {
                Assert.Equal(names[i], fields[i]);
            }

            var values = "111,Stone,大石头,1,36.6,1984-07-01,2020-03-04 20:08:45,323.452,0.234".Split(",");
            var row1 = rows[1];
            Assert.Equal(values.Length, row1.Length);
            for (var i = 0; i < values.Length; i++)
            {
                Assert.Equal(values[i], row1[i]);
            }
        }

        //[Fact]
        public void Test2()
        {
            var reader = new ExcelReader("test.xlsx");
            var rows = reader.ReadRows().ToList();
            Assert.Equal(927, rows.Count);
        }
    }
}