首次提交:本地项目同步到Gitea

This commit is contained in:
zhusenlin
2026-01-24 08:45:54 +08:00
commit 4a6b23db69
256 changed files with 25311 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Io.Github.Kerwinxu.LibShapes.Core.Command;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Io.Github.Kerwinxu.LibShapes.Core.Command.Tests
{
[TestClass()]
public class CommandRecorderTests
{
[TestMethod()]
public void UndoTest()
{
//// 这个是测试一下是否可以有undo和redo
//// 1. 先有画布
//UserControlCanvas canvas = new UserControlCanvas();
//// 2. 然后新建一个线段
//Shape.ShapeLine line = new Shape.ShapeLine() {
// X=10,
// Y=20,
// Width=30,
// Height=40
//};
////手动添加进去
//canvas.addShape(line);
//// 需要手动建立这个新建命令
//// todo
////canvas.commandRecorder.addCommand(
//// new Command.CommandCreate() {
//// canvas = canvas,
//// NewShape=line
//// });
//// 3. 添加一个矩形
//Shape.ShapeRectangle rect = new Shape.ShapeRectangle()
//{
// X = 50,
// Y = 60,
// Width = 70,
// Height = 80
//};
////手动添加进去
//canvas.addShape(rect);
//// 需要手动建立这个新建命令
//canvas.commandRecorder.addCommand(
// new Command.CommandCreate()
// {
// canvas = canvas,
// NewShape = rect
// });
//// 4. 删除最后一个
//canvas.changeSelect(rect);
//canvas.deleteShapes();
//// 5. 判断有几个形状
//Assert.AreEqual(1, canvas.shapes.lstShapes.Count);
//// 6. 然后执行undo
//canvas.commandRecorder.Undo();
//// 7. 判断有几个形状
//Assert.AreEqual(2, canvas.shapes.lstShapes.Count);
//// 8. 执行redo
//canvas.commandRecorder.Redo();
//// 9. 判断有几个形状
//Assert.AreEqual(1, canvas.shapes.lstShapes.Count);
}
}
}

View File

@@ -0,0 +1,29 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Io.Github.Kerwinxu.LibShapes.Core.Shape;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Io.Github.Kerwinxu.LibShapes.Core.Shape.Tests
{
[TestClass()]
public class ShapeEleTests
{
[TestMethod()]
public void DeepCloneTest()
{
// 这里用一个线段来测试一下
var line1 = new ShapeLine();
line1.X = 10;
line1.Y = 20;
line1.Width = 30;
line1.Height = 40;
var line1_2 = line1.DeepClone();
Assert.AreEqual<ShapeLine>(line1, (ShapeLine)line1_2);
//Assert.Fail();
}
}
}

View File

@@ -0,0 +1,27 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Io.Github.Kerwinxu.LibShapes.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Io.Github.Kerwinxu.LibShapes.Core.Serialize;
namespace Io.Github.Kerwinxu.LibShapes.Core.Tests
{
[TestClass()]
public class ShapesTests
{
[TestMethod()]
public void DeepCloneTest()
{
// 先测试一个空白的Shape
Shapes shapes = new Shapes();
JsonSerialize jsonSerialize = new JsonSerialize();
string json = jsonSerialize.SerializeObject(shapes);
var shapes2 = jsonSerialize.DeserializeObject<Shapes>(json);
Assert.AreNotEqual(shapes2, null);
//Assert.Fail();
}
}
}