From d154318e82fe2db8d5fae42e6f45307ed84cc46e Mon Sep 17 00:00:00 2001 From: Jeffrey Su Date: Wed, 26 Jun 2024 07:09:08 +0800 Subject: [PATCH] #2708 add Add a judgment to the graph constructor (#2709) * #2708 add Add a judgment to the graph constructor * #2708 add Add a judgment to the graph constructor & added unit test * #2708 #2079 move GraphTests to AutoGen.Tests; delete AutoGen.Core.Tests project --- dotnet/AutoGen.sln | 4 ++-- dotnet/src/AutoGen.Core/GroupChat/Graph.cs | 11 +++++++++-- .../test/AutoGen.Tests/GroupChat/GraphTests.cs | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs diff --git a/dotnet/AutoGen.sln b/dotnet/AutoGen.sln index 5ecfe193887..cd1d683406c 100644 --- a/dotnet/AutoGen.sln +++ b/dotnet/AutoGen.sln @@ -1,4 +1,4 @@ - + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.8.34322.80 @@ -206,4 +206,4 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {93384647-528D-46C8-922C-8DB36A382F0B} EndGlobalSection -EndGlobal +EndGlobal \ No newline at end of file diff --git a/dotnet/src/AutoGen.Core/GroupChat/Graph.cs b/dotnet/src/AutoGen.Core/GroupChat/Graph.cs index 02f4da50bae..d6b71e2a3f1 100644 --- a/dotnet/src/AutoGen.Core/GroupChat/Graph.cs +++ b/dotnet/src/AutoGen.Core/GroupChat/Graph.cs @@ -12,9 +12,16 @@ public class Graph { private readonly List transitions = new List(); - public Graph(IEnumerable transitions) + public Graph() { - this.transitions.AddRange(transitions); + } + + public Graph(IEnumerable? transitions) + { + if (transitions != null) + { + this.transitions.AddRange(transitions); + } } public void AddTransition(Transition transition) diff --git a/dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs b/dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs new file mode 100644 index 00000000000..77e2c99dcd1 --- /dev/null +++ b/dotnet/test/AutoGen.Tests/GroupChat/GraphTests.cs @@ -0,0 +1,18 @@ + +using Xunit; + +namespace AutoGen.Tests +{ + public class GraphTests + { + [Fact] + public void GraphTest() + { + var graph1 = new Graph(); + Assert.NotNull(graph1); + + var graph2 = new Graph(null); + Assert.NotNull(graph2); + } + } +}