39 lines
1018 B
C#
39 lines
1018 B
C#
|
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; } = "";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|