Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldelaparra committed Oct 25, 2020
1 parent 138efd5 commit 0935e35
Show file tree
Hide file tree
Showing 8 changed files with 104,442 additions and 51 deletions.
73 changes: 26 additions & 47 deletions ModelToRdf.UnitTests/DeserializationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,54 @@ namespace ModelToRdf.UnitTests
public class DeserializationTests
{
[Fact]
public void ConvertJsonToRDF()
public void ConvertSample1ToRDF()
{
var jsonFile = @"Resources/test1.json";
var jsonDictionary = jsonFile.XmlOrJsonFilenameToJsonData();
var xmlFile = @"Resources/sample1.pcmm";
var jsonDictionary = xmlFile.XmlOrJsonFilenameToJsonData();
var graph = jsonDictionary.ToRDFGraph();

Assert.NotNull(graph);

//var writer = new NTriplesWriter() { SortTriples = true };
//writer.Save(graph, @"graph.json.nt");
}

[Fact]
public void NonRes_ConvertJsonToRDF()
public void ConvertSample2ToRDF()
{
var jsonFile = @"C:\Dev\PGGA\PGGA.E3.RDF.UnitTest\Resources\test3.json";
var jsonDictionary = jsonFile.XmlOrJsonFilenameToJsonData();
const string file = @"Resources/sample2.pcmm";
var jsonDictionary = file.XmlOrJsonFilenameToJsonData();
var graph = jsonDictionary.ToRDFGraph();
var writer = new NTriplesWriter() { SortTriples = true };
writer.Save(graph, @"graph3.nt");
Assert.NotNull(graph);
}

[Fact]
public void ConvertXmlToRDF()
public void ConvertSample3ToRDF()
{
var xmlFile = @"C:\Users\CHGADEL1\Desktop\Projects\21878\sample2.pcmm";
var jsonDictionary = xmlFile.XmlOrJsonFilenameToJsonData();
const string file = @"Resources/sample3.json";
var jsonDictionary = file.XmlOrJsonFilenameToJsonData();
var graph = jsonDictionary.ToRDFGraph();
var writer = new NTriplesWriter() { SortTriples = true };
writer.Save(graph, @"C:\Users\CHGADEL1\Desktop\Projects\21878\xmlRdf2.nt");
Assert.NotNull(graph);
}

public void NonRes_ConvertXMLToRDF()
[Fact]
public void ConvertSample4ToRDF()
{
var xmlFile = @"C:\Users\CHGADEL1\Desktop\ASK - Common BCU IED\REC670_Template1.pcmm";
var jsonDictionary = xmlFile.XmlOrJsonFilenameToJsonData();
var jsonFile = @"Resources/sample4.json";
var jsonDictionary = jsonFile.XmlOrJsonFilenameToJsonData();
var graph = jsonDictionary.ToRDFGraph();
var writer = new NTriplesWriter() { SortTriples = true };
writer.Save(graph, @"C:\Users\CHGADEL1\Desktop\ASK - Common BCU IED\xmlRdf2.nt");
Assert.NotNull(graph);
}

[Fact]
public void Z0_AllPCMMToRDF()
public void ConvertSample5ToRDF()
{
const string path = @"C:\Users\CHGADEL1\Desktop\Projects\21878\PCMM\";
var files = Directory.EnumerateFiles(path, "*.pcmm", SearchOption.AllDirectories);

foreach (var file in files)
{
var jsonDictionary = file.XmlOrJsonFilenameToJsonData();
var graph = jsonDictionary.ToRDFGraph();
var writer = new NTriplesWriter() { SortTriples = true };
writer.Save(graph, $"{file}.nt");
}
var jsonFile = @"Resources/sample5.xml";
var jsonDictionary = jsonFile.XmlOrJsonFilenameToJsonData();
var graph = jsonDictionary.ToRDFGraph();
Assert.NotNull(graph);
}

[Fact]
public void Z0_AllJsonToRDF()
public void ConvertSample6ToRDF()
{
const string path = @"C:\Users\CHGADEL1\Desktop\SubAssemblies\Export\JSON\";
var files = Directory.EnumerateFiles(path, "*.json", SearchOption.AllDirectories);

foreach (var file in files.Skip(69))
{
var jsonDictionary = file.XmlOrJsonFilenameToJsonData();
var graph = jsonDictionary.ToRDFGraph();
var writer = new NTriplesWriter() { SortTriples = true };
writer.Save(graph, $"{file}.nt");
}
var jsonFile = @"Resources/sample6.json";
var jsonDictionary = jsonFile.XmlOrJsonFilenameToJsonData();
var graph = jsonDictionary.ToRDFGraph();
Assert.NotNull(graph);
}
}
}
24 changes: 20 additions & 4 deletions ModelToRdf.UnitTests/ModelToRdf.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\test1.json" />
<None Remove="Resources\test1.xml" />
<None Remove="Resources\sample1.pcmm" />
<None Remove="Resources\sample2.pcmm" />
<None Remove="Resources\sample3.json" />
<None Remove="Resources\sample4.json" />
<None Remove="Resources\sample5.xml" />
<None Remove="Resources\sample6.json" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,10 +24,22 @@
</ItemGroup>

<ItemGroup>
<Content Include="Resources\test1.json">
<Content Include="Resources\sample1.pcmm">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\test1.xml">
<Content Include="Resources\sample2.pcmm">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\sample3.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\sample4.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\sample5.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\sample6.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
Expand Down
Loading

0 comments on commit 0935e35

Please sign in to comment.