Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cbries committed Mar 7, 2021
1 parent 677f991 commit 19a25f0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion EcosApp/theme/RailwayEssential.Test.html

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions Testing/TrackPlanerTest/TestMetamodel.cs
Expand Up @@ -14,6 +14,9 @@ namespace TrackPlanerTest
[TestClass]
public class TestMetamodel
{
public static string WorkspaceRoot = @"..\..\..\..\..\Workspaces\";
public static string ThemeRoot = @"..\..\..\..\..\EcosApp\theme\";

private PlanField LoadPlanFieldFile(string path)
{
File.Exists(path).Should().BeTrue();
Expand Down Expand Up @@ -189,7 +192,7 @@ public void TestSerializationPlanField()
[TestMethod]
public void TestCheckTrack()
{
var path = @"..\..\..\..\rocrail2ecosApp\Demos\metamodel.RocrailDemo.json";
var path = WorkspaceRoot + @"RocrailDemo\metamodel.json";
var field = LoadPlanFieldFile(path);

var tr0 = field["14x4"];
Expand Down Expand Up @@ -471,7 +474,7 @@ public void TestRoutingD()
[TestMethod]
public void TestRoutingRocrailDemo()
{
var path = @"..\..\..\..\rocrail2ecosApp\Demos\metamodel.RocrailDemo.json";
var path = WorkspaceRoot + @"RocrailDemo\metamodel.json";
var field = LoadPlanFieldFile(path);

var bk5_1 = field["5x1"];
Expand Down Expand Up @@ -533,12 +536,12 @@ public void TestRoutingConnectorDemo()
[TestMethod]
public void TestRoutingBasementDemo()
{
var path = @"..\..\..\..\rocrail2ecosApp\Demos\metamodel.BasementDemo.json";
var path = WorkspaceRoot + @"Basement\metamodel.json";
var field = LoadPlanFieldFile(path);

var startBlock = field["8x9"];
var r8_9 = field.GetRoutes(startBlock);
var targetBlock = field["14x18"];
var targetBlock = field["21x18"];
foreach (var itR in r8_9)
{
if (itR.Target.identifier == targetBlock.identifier)
Expand All @@ -557,7 +560,7 @@ public void TestRoutingBasementDemo()
}

var allBlocks = field.GetBlocks();
allBlocks.Count.Should().Be(22);
allBlocks.Count.Should().Be(21);

var step = 0;
var maxStep = allBlocks.Count;
Expand All @@ -574,7 +577,7 @@ public void TestRoutingBasementDemo()
ShowProgress(step, maxStep, $"Analyzing Basement (Current routes: {totalRoutes})");
}

totalRoutes.Should().Be(142);
totalRoutes.Should().Be(210);

Trace.WriteLine($"Found {totalRoutes} routes.");
}
Expand Down Expand Up @@ -685,15 +688,15 @@ public void TestCrossingSwitchDirections2()
[TestMethod]
public void TestAnalyzer()
{
var path = @"..\..\..\..\rocrail2ecosApp\Demos\metamodel.BasementDemo.json";
var path = WorkspaceRoot + @"Basement\metamodel.json";
var field = LoadPlanFieldFile(path);

var analyzer = new Analyze(field);
var analyzerResult = analyzer.Execute((step, maxSteps) =>
{
ShowProgress(step, maxSteps, "Analyzing Basement");
});
analyzerResult.NumberOfRoutes.Should().Be(142);
analyzerResult.NumberOfRoutes.Should().Be(210);

var json = analyzerResult.ToJson();
json.Length.Should().BeGreaterThan(0);
Expand Down
4 changes: 2 additions & 2 deletions Testing/TrackPlanerTest/TestSerializations.cs
Expand Up @@ -16,7 +16,7 @@ public class TestSerializations
[TestMethod]
public void TestSerializationPlanField()
{
var path = @"..\..\..\..\rocrail2ecosApp\Demos\metamodel.RocrailDemo.json";
var path = TestMetamodel.WorkspaceRoot + @"RocrailDemo\metamodel.json";
File.Exists(path).Should().BeTrue();

var json = File.ReadAllText(path, Encoding.UTF8);
Expand All @@ -27,7 +27,7 @@ public void TestSerializationPlanField()
[TestMethod]
public void TestDeserializationOfTheme()
{
var path = @"..\..\..\..\EcosApp\theme\RailwayEssential.json";
var path = TestMetamodel.ThemeRoot + @"RailwayEssential.json";
File.Exists(path).Should().BeTrue();

var json = File.ReadAllText(path, Encoding.UTF8);
Expand Down
4 changes: 2 additions & 2 deletions Testing/TrackPlanerTest/TestTheme.cs
Expand Up @@ -15,8 +15,8 @@ public class TestTheme
[TestMethod]
public void TestIconsRendering()
{
var path = @"C:\tfs\cbriesGitHub\ecoslib\ecoslib\EcosApp\theme\RailwayEssential.json";
var pathToFiles = @"C:\tfs\cbriesGitHub\ecoslib\ecoslib\EcosApp\theme\RailwayEssential";
var path = TestMetamodel.ThemeRoot + @"RailwayEssential.json";
var pathToFiles = TestMetamodel.ThemeRoot + @"RailwayEssential";
var targetHtmlFile = Path.Combine(Path.GetDirectoryName(path), "RailwayEssential.Test.html");
File.Exists(path).Should().BeTrue();

Expand Down

0 comments on commit 19a25f0

Please sign in to comment.