Xnl序列化空字符串测试

This commit is contained in:
FalconFly 2023-06-21 08:49:19 +08:00
parent 205df40786
commit ef717dfca5

View File

@ -0,0 +1,38 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Falcon.SugarApi.XmlSerialize;
using System;
namespace Falcon.SugarApi.Test
{
/// <summary>
/// xml序列化测试
/// </summary>
[TestClass]
public class XmlSerializeTest
{
/// <summary>
/// 一般xml序列化测试
/// </summary>
[TestMethod]
public void JsonSerializeDITest() {
IXmlSerialize ser = new XmlSerializeFactory().CreateXmlSerialize(s => {
});
Assert.IsNotNull(ser);
var obj = new XmlObject();
var str = ser.Serialize(obj);
Assert.IsNotNull(str);
Console.WriteLine(str);
Assert.IsTrue(str.IndexOf("NullStr") >= 0);
}
public class XmlObject
{
public string? NullStr { get; set; } = null;
public string? EmptyStr { get; set; } = string.Empty;
public string? EmptyStr2 { get; set; } = "";
}
}
}