Skip to content

Commit 27d2af9

Browse files
authored
Merge pull request #3 from anno-mods/devel/v0.3
save/export to a7tinfo, xml
2 parents 494e011 + c1190e7 commit 27d2af9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2974
-397
lines changed

.github/workflows/main.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ jobs:
3131
- name: Build
3232
run: dotnet build --no-restore
3333

34-
#- name: Test
35-
# run: dotnet test --no-build --verbosity normal
34+
- name: Test
35+
run: dotnet test --no-build --verbosity normal
3636

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

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

4343
- name: Upload
4444
uses: actions/upload-artifact@v2
4545
with:
4646
name: AnnoMapEditor
47-
path: AnnoMapEditor.zip
47+
path: Build/AnnoMapEditor.exe
4848
if-no-files-found: error
4949

5050
- name: Release
@@ -55,4 +55,4 @@ jobs:
5555
body: |
5656
Introduction in [readme](https://github.com/anno-mods/AnnoMapEditor/blob/${{ github.sha }}/README.md).
5757
files: |
58-
AnnoMapEditor.zip
58+
Build/AnnoMapEditor.exe
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0-windows</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
8+
<IsPackable>false</IsPackable>
9+
<IsPublishable>false</IsPublishable>
10+
<PlatformTarget>x64</PlatformTarget>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
15+
<PackageReference Include="xunit" Version="2.4.1" />
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
17+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
18+
<PrivateAssets>all</PrivateAssets>
19+
</PackageReference>
20+
<PackageReference Include="coverlet.collector" Version="3.1.2">
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
<PrivateAssets>all</PrivateAssets>
23+
</PackageReference>
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include="..\AnnoMapEditor\AnnoMapEditor.csproj" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<None Update="TestMaps\campaign_chapter03_colony01.xml">
32+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
33+
</None>
34+
<None Update="TestMaps\colony02_01.xml">
35+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
36+
</None>
37+
<None Update="TestMaps\moderate_c_01.xml">
38+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
39+
</None>
40+
<None Update="TestMaps\moderate_islandarc_ss_01.xml">
41+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
42+
</None>
43+
<None Update="TestMaps\scenario_02_colony_01.xml">
44+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
45+
</None>
46+
</ItemGroup>
47+
48+
</Project>

AnnoMapEditor.UnitTests/RoundTrip.cs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using AnnoMapEditor.MapTemplates;
2+
using AnnoMapEditor.MapTemplates.Serializing;
3+
using AnnoMapEditor.UnitTests.Utils;
4+
5+
namespace AnnoMapEditor.UnitTests
6+
{
7+
public class RoundTrip
8+
{
9+
[Theory]
10+
[InlineData("./TestMaps/moderate_c_01.xml")]
11+
[InlineData("./TestMaps/campaign_chapter03_colony01.xml")]
12+
[InlineData("./TestMaps/moderate_islandarc_ss_01.xml")]
13+
[InlineData("./TestMaps/colony02_01.xml")]
14+
[InlineData("./TestMaps/scenario_02_colony_01.xml")]
15+
public async Task XmlToA7tinfoToXml(string filePath)
16+
{
17+
using Stream inputXml = File.OpenRead(filePath);
18+
Session? session = await Session.FromXmlAsync(inputXml, filePath);
19+
20+
Assert.NotNull(session);
21+
22+
Stream a7tinfo = new MemoryStream();
23+
var export = session!.ToTemplate();
24+
Assert.NotNull(export);
25+
await Serializer.WriteAsync(export!, a7tinfo);
26+
27+
a7tinfo.Position = 0;
28+
session = await Session.FromA7tinfoAsync(a7tinfo, filePath);
29+
Assert.NotNull(session);
30+
31+
StreamWriter outputXml = new(new MemoryStream());
32+
var template = session!.ToTemplate();
33+
Assert.NotNull(template);
34+
await Serializer.WriteToXmlAsync(template!, outputXml.BaseStream);
35+
36+
Assert.True(StreamComparer.AreEqual(inputXml, outputXml.BaseStream));
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)