Skip to content

Commit 35295c3

Browse files
committed
+ tests
1 parent 9d6edff commit 35295c3

3 files changed

Lines changed: 53 additions & 2 deletions

File tree

PSGraph.Tests/ExportGraphViewCmdletTests.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using QuikGraph.Serialization;
1111
using System.Text.Json;
1212
using PSGraph.Vega.Extensions;
13+
using System.Runtime.CompilerServices;
1314

1415
namespace PSGraph.Tests
1516
{
@@ -203,6 +204,38 @@ public void ExportGraph_NoPathProvided_ReturnsVegaString()
203204

204205
}
205206

207+
208+
[Fact]
209+
public void ExportGraph_PathProvided_DoesNotThrow()
210+
{
211+
// Arrange
212+
var graph = CreateSampleGraph();
213+
214+
var records = graph.ConvertToVegaNodeLink();
215+
216+
var vegaNames = Enum.GetNames(typeof(GraphExportTypes))
217+
.Where(name => name.StartsWith("Vega"))
218+
.ToList();
219+
220+
foreach (var vegaName in vegaNames)
221+
{
222+
foreach (var ext in new string[] { "html", "json" })
223+
{
224+
var filePath = Path.Combine(_tempDirectory, $"{vegaName}.{ext}");
225+
_powershell.AddCommand("Export-Graph")
226+
.AddParameter("Graph", graph)
227+
.AddParameter("Format", $"{vegaName}")
228+
.AddParameter("Path", filePath);
229+
230+
// Act
231+
var results = _powershell.Invoke();
232+
233+
_powershell.Commands.Clear();
234+
}
235+
}
236+
237+
}
238+
206239
[Fact]
207240
public void ExportGraph_InvalidPath_ThrowsException()
208241
{

PSGraph.Tests/NewPSGraphTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ public void NewGraph_CreatesEmptyGraph()
4343
graph.EdgeCount.Should().Be(0);
4444
}
4545

46+
[Fact]
47+
public void NewGraph_CreatesEmptyAdjGraph()
48+
{
49+
// Arrange
50+
_powershell.AddCommand("New-AdjacencyGraph");
51+
52+
// Act
53+
var results = _powershell.Invoke();
54+
55+
// Assert
56+
results.Should().NotBeNullOrEmpty();
57+
results.Count.Should().Be(1);
58+
var graph = results[0].BaseObject as PsAdjacencyGraph;
59+
graph.Should().NotBeNull();
60+
graph.VertexCount.Should().Be(0);
61+
graph.EdgeCount.Should().Be(0);
62+
}
63+
4664
[Fact]
4765
public void NewGraph_WithInvalidParameter_ThrowsException()
4866
{

PsGraph.Pester.Tests/PSGraph.Vega.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Describe 'Vega Tests' {
2626
Add-Edge -From H -To I -Graph $graph | Out-Null
2727
Add-Edge -From M -To B -Graph $graph | Out-Null
2828

29-
Export-Graph -Graph $graph -Format Vega_ForceDirected -Path /tmp/x.force.html
29+
Export-Graph -Graph $graph -Format Vega_ForceDirected -Path '/tmp/x.force.html'
3030
}
3131

3232
It 'Vega Tree Layout' {
@@ -51,7 +51,7 @@ Describe 'Vega Tests' {
5151
Add-Edge -From B -To E -Graph $graph | Out-Null
5252
Add-Edge -From C -To F -Graph $graph | Out-Null
5353

54-
Export-Graph -Graph $graph -Format Vega_TreeLayout -Path /tmp/x.tree.htmlß
54+
Export-Graph -Graph $graph -Format Vega_TreeLayout -Path /tmp/x.tree.html
5555
}
5656

5757
It 'Vega Adjacency Matrix' {

0 commit comments

Comments
 (0)