Skip to content

Commit

Permalink
Refacor reading and writing gurka
Browse files Browse the repository at this point in the history
  • Loading branch information
skjohansen committed Aug 15, 2024
1 parent dd4a4ac commit bd84b24
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**/.vs
**/bin
**/obj
source/SpecGurka/appsettings.json
source/GenGurka/App.config
**/TestResults
**/TestResults
source/SyncGurka/appsettings.json
8 changes: 7 additions & 1 deletion VizGurka.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34928.147
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VizGurka", "source\VizGurka\VizGurka.csproj", "{9B0404AE-B976-434F-BF1E-5667597021E0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VizGurka", "source\VizGurka\VizGurka.csproj", "{9B0404AE-B976-434F-BF1E-5667597021E0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GurkaSpec", "source\GurkaSpec\GurkaSpec.csproj", "{5347A6E1-0AB2-473C-A339-C6BAE144015B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +17,10 @@ Global
{9B0404AE-B976-434F-BF1E-5667597021E0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B0404AE-B976-434F-BF1E-5667597021E0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B0404AE-B976-434F-BF1E-5667597021E0}.Release|Any CPU.Build.0 = Release|Any CPU
{5347A6E1-0AB2-473C-A339-C6BAE144015B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5347A6E1-0AB2-473C-A339-C6BAE144015B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5347A6E1-0AB2-473C-A339-C6BAE144015B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5347A6E1-0AB2-473C-A339-C6BAE144015B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion source/GenGurka/GenGurka.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\GurkaSpec\GurkaSpec.csproj" />
<ProjectReference Include="..\GurkaSpec\GurkaSpec.csproj" />
</ItemGroup>

</Project>
15 changes: 1 addition & 14 deletions source/GenGurka/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,7 @@
// exc time



XmlSerializer xsSubmit = new XmlSerializer(typeof(Testrun));
var xml = "";

using (var sww = new StringWriter())
{
using (XmlWriter writer = XmlWriter.Create(sww))
{
xsSubmit.Serialize(writer, gurka);
xml = sww.ToString(); // Your XML
}
}

System.IO.File.WriteAllText($"{ConfigurationManager.AppSettings["outputpath"]}testrun_{DateTime.UtcNow.ToString("s").Replace(':','_')}.gurka", xml);
Gurka.WriteGurkaFile(ConfigurationManager.AppSettings["outputpath"], gurka);

Console.WriteLine("heelo");

Expand Down
13 changes: 13 additions & 0 deletions source/GurkaSpec/Background.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SpecGurka.GurkaSpec
{
public class Background
{
public string Name { get; set; }
}
}
37 changes: 37 additions & 0 deletions source/GurkaSpec/Gurka.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Xml.Serialization;
using System.Xml;

namespace SpecGurka.GurkaSpec
{
public class Gurka
{
public static Testrun ReadGurkaFile(string path)
{
var xml = System.IO.File.ReadAllText(path);
XmlSerializer serializer = new XmlSerializer(typeof(Testrun));
Testrun result;
using (TextReader reader = new StringReader(xml))
{
result = (Testrun)serializer.Deserialize(reader);
}
return result;
}

public static void WriteGurkaFile(string path, Testrun testrun)
{
XmlSerializer xsSubmit = new XmlSerializer(typeof(Testrun));
var xml = "";

using (var sww = new StringWriter())
{
using (XmlWriter writer = XmlWriter.Create(sww))
{
xsSubmit.Serialize(writer, testrun);
xml = sww.ToString(); // Your XML
}
}

System.IO.File.WriteAllText($"{path}testrun_{DateTime.UtcNow.ToString("s").Replace(':', '_')}.gurka", xml);
}
}
}
13 changes: 13 additions & 0 deletions source/GurkaSpec/Rule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SpecGurka.GurkaSpec
{
public class Rule
{
public string Name { get; set; }
}
}
7 changes: 1 addition & 6 deletions source/GurkaSpec/Scenario.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Xml.Serialization;

namespace SpecGurka.GurkaSpec
Expand Down
4 changes: 4 additions & 0 deletions source/VizGurka/VizGurka.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\GurkaSpec\GurkaSpec.csproj" />
</ItemGroup>

</Project>

0 comments on commit bd84b24

Please sign in to comment.