Falcon.Extend/Falcon.ExtendTests/ObjectExtendTests.cs

46 lines
1.4 KiB
C#
Raw Permalink Normal View History

2019-12-27 17:15:43 +08:00
using Microsoft.VisualStudio.TestTools.UnitTesting;
2019-12-31 13:52:29 +08:00
using Falcon.Extend;
2019-12-27 17:15:43 +08:00
using System;
using System.Collections.Generic;
using System.Text;
2019-12-31 13:52:29 +08:00
namespace Falcon.Extend.Tests
2019-12-27 17:15:43 +08:00
{
[TestClass()]
public class ObjectExtendTests
{
[TestMethod()]
public void CopyToTest() {
var o1 = new Obj1 {
Id = 1,
Name = "Tom",
BirthDay = new DateTime(2019,8,5),
};
var o2 = new Obj2 {
BirthDay = DateTimeOffset.Parse("2019-8-5"),
};
//测试一般复制
o1.CopyTo(o2);
Assert.IsTrue(o2.Id == o1.Id,"int 复制错误");
Assert.IsTrue(o2.Name == o1.Name,"string 复制错误");
Assert.IsTrue(o2.BirthDay.Year == o1.BirthDay.Year,"DateTime到DateTimeOffset复制错误");
Assert.IsTrue(o2.BirthDay.Month == o1.BirthDay.Month,"DateTime到DateTimeOffset复制错误");
Assert.IsTrue(o2.BirthDay.Day == o1.BirthDay.Day,"DateTime到DateTimeOffset复制错误");
}
}
class Obj1
{
public int Id { get; set; }
public string Name { get; set; }
public DateTime BirthDay { get; set; }
}
class Obj2
{
public int Id { get; set; }
public string Name { get; set; }
public DateTimeOffset BirthDay { get; set; }
}
}