using Microsoft.VisualStudio.TestTools.UnitTesting; using Falcon.Extend; using System; using System.Collections.Generic; using System.Text; namespace Falcon.Extend.Tests { [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; } } }