-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from anno-mods/devel/v0.3
save/export to a7tinfo, xml
- Loading branch information
Showing
43 changed files
with
2,974 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
} |
Oops, something went wrong.