FileSqlServerSync/Server/LocalServer/LocalSyncServerFactory.cs
zerlei 78d9e68fea refactor:将每个测试方法改为相互独立
原因是:

1.  相互独立的单元测试,有助于debug问题,
2.  不需要考虑执行顺序,额外的运行环境等,更加简单。
做的工作是:
1. 去掉了顺序执行,这有助于并发调用,减少测试时间
2. 去掉了测试方法中共享的实例
2024-10-12 22:00:25 +08:00

23 lines
565 B
C#

using System.Net.WebSockets;
namespace LocalServer;
public class LocalSyncServerFactory
{
public void CreateLocalSyncServer(WebSocket socket, string name)
{
if (Servers.Select(x => x.Name == name).Any())
{
throw new Exception("there already is a server with that name is Runing!");
}
Servers.Add(new LocalSyncServer(socket, name, this));
}
private readonly List<LocalSyncServer> Servers = [];
public void RemoveLocalSyncServer(LocalSyncServer server)
{
Servers.Remove(server);
}
}