Add CMP tests for non-quote serialization

This commit is contained in:
Matt Nadareski
2025-05-28 09:51:45 -04:00
parent ddef42126b
commit 6351cabb62

View File

@@ -1,4 +1,3 @@
using System;
using System.IO;
using System.Linq;
using SabreTools.Serialization.Deserializers;
@@ -96,6 +95,31 @@ namespace SabreTools.Serialization.Test.Deserializers
Validate(newGame);
}
[Fact]
public void RoundTripGameWithoutQuotesTest()
{
// Get the serializer and deserializer
var deserializer = new Serialization.Deserializers.ClrMamePro();
var serializer = new Serialization.Serializers.ClrMamePro();
// Build the data
Models.ClrMamePro.MetadataFile mf = Build(game: true);
// Serialize to stream
Stream? actual = serializer.Serialize(mf, quotes: false);
Assert.NotNull(actual);
// Serialize back to original model
Models.ClrMamePro.MetadataFile? newMf = deserializer.Deserialize(actual);
// Validate the data
Assert.NotNull(newMf);
Validate(newMf.ClrMamePro);
Assert.NotNull(newMf.Game);
var newGame = Assert.Single(newMf.Game);
Validate(newGame);
}
[Fact]
public void RoundTripMachineTest()
{
@@ -121,6 +145,31 @@ namespace SabreTools.Serialization.Test.Deserializers
Validate(newGame);
}
[Fact]
public void RoundTripMachineWithoutQuotesTest()
{
// Get the serializer and deserializer
var deserializer = new Serialization.Deserializers.ClrMamePro();
var serializer = new Serialization.Serializers.ClrMamePro();
// Build the data
Models.ClrMamePro.MetadataFile mf = Build(game: false);
// Serialize to stream
Stream? actual = serializer.Serialize(mf, quotes: false);
Assert.NotNull(actual);
// Serialize back to original model
Models.ClrMamePro.MetadataFile? newMf = deserializer.Deserialize(actual);
// Validate the data
Assert.NotNull(newMf);
Validate(newMf.ClrMamePro);
Assert.NotNull(newMf.Game);
var newGame = Assert.Single(newMf.Game);
Validate(newGame);
}
/// <summary>
/// Build model for serialization and deserialization
/// </summary>