Skip to content

Commit

Permalink
Merge pull request #3 from anno-mods/devel/v0.3
Browse files Browse the repository at this point in the history
save/export to a7tinfo, xml
  • Loading branch information
jakobharder authored Jun 15, 2022
2 parents 494e011 + c1190e7 commit 27d2af9
Show file tree
Hide file tree
Showing 43 changed files with 2,974 additions and 397 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ jobs:
- name: Build
run: dotnet build --no-restore

#- name: Test
# run: dotnet test --no-build --verbosity normal
- name: Test
run: dotnet test --no-build --verbosity normal

- name: Publish
run: dotnet publish -c Release -o Build -r win-x64 -p:PublishTrimmed=false -p:PublishSingleFile=true --self-contained false

- name: Package
run: tar --exclude='*.pdb' -caf AnnoMapEditor.zip Build/*
#- name: Package
# run: tar --exclude='*.pdb' -caf AnnoMapEditor.zip -C ./Build/ *

- name: Upload
uses: actions/upload-artifact@v2
with:
name: AnnoMapEditor
path: AnnoMapEditor.zip
path: Build/AnnoMapEditor.exe
if-no-files-found: error

- name: Release
Expand All @@ -55,4 +55,4 @@ jobs:
body: |
Introduction in [readme](https://github.com/anno-mods/AnnoMapEditor/blob/${{ github.sha }}/README.md).
files: |
AnnoMapEditor.zip
Build/AnnoMapEditor.exe
48 changes: 48 additions & 0 deletions AnnoMapEditor.UnitTests/AnnoMapEditor.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsPublishable>false</IsPublishable>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

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

<ItemGroup>
<None Update="TestMaps\campaign_chapter03_colony01.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestMaps\colony02_01.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestMaps\moderate_c_01.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestMaps\moderate_islandarc_ss_01.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="TestMaps\scenario_02_colony_01.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
39 changes: 39 additions & 0 deletions AnnoMapEditor.UnitTests/RoundTrip.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using AnnoMapEditor.MapTemplates;
using AnnoMapEditor.MapTemplates.Serializing;
using AnnoMapEditor.UnitTests.Utils;

namespace AnnoMapEditor.UnitTests
{
public class RoundTrip
{
[Theory]
[InlineData("./TestMaps/moderate_c_01.xml")]
[InlineData("./TestMaps/campaign_chapter03_colony01.xml")]
[InlineData("./TestMaps/moderate_islandarc_ss_01.xml")]
[InlineData("./TestMaps/colony02_01.xml")]
[InlineData("./TestMaps/scenario_02_colony_01.xml")]
public async Task XmlToA7tinfoToXml(string filePath)
{
using Stream inputXml = File.OpenRead(filePath);
Session? session = await Session.FromXmlAsync(inputXml, filePath);

Assert.NotNull(session);

Stream a7tinfo = new MemoryStream();
var export = session!.ToTemplate();
Assert.NotNull(export);
await Serializer.WriteAsync(export!, a7tinfo);

a7tinfo.Position = 0;
session = await Session.FromA7tinfoAsync(a7tinfo, filePath);
Assert.NotNull(session);

StreamWriter outputXml = new(new MemoryStream());
var template = session!.ToTemplate();
Assert.NotNull(template);
await Serializer.WriteToXmlAsync(template!, outputXml.BaseStream);

Assert.True(StreamComparer.AreEqual(inputXml, outputXml.BaseStream));
}
}
}
Loading

0 comments on commit 27d2af9

Please sign in to comment.