Falcon.SugarApi/CSharpTest/UnitTest1.cs

31 lines
761 B
C#
Raw Normal View History

2024-07-25 11:46:05 +08:00
using System.Text.Json;
namespace CSharpTest
{
public record Person(string name,int age);
public class RecordTests
{
[SetUp]
public void Setup() {
}
[Test]
public void Test1() {
var p1 = new Person("<22><><EFBFBD><EFBFBD>",40);
var p2 = p1 with { age = 50 };
Console.WriteLine(p1 == p2);
Console.WriteLine(p1.Equals(p2));
Console.WriteLine(p1.ToString());
Console.WriteLine(JsonSerializer.Serialize(p1));
Console.WriteLine(JsonSerializer.Serialize(p2));
var p3 = new Person("<22><><EFBFBD><EFBFBD>",40);
var p4 = new Person("<22><><EFBFBD><EFBFBD>",40);
Console.WriteLine(p3 == p4);
Assert.IsTrue(p3 == p4);
}
}
}