mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
Add AutoTranslatePayload re-encode test
This commit is contained in:
parent
c03e7ecfe6
commit
0bb87d87b7
1 changed files with 32 additions and 3 deletions
|
|
@ -1,6 +1,10 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Dalamud.Configuration;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
|
||||
using Xunit;
|
||||
|
||||
namespace Dalamud.Test.Game.Text.SeStringHandling
|
||||
|
|
@ -50,19 +54,44 @@ namespace Dalamud.Test.Game.Text.SeStringHandling
|
|||
var config = new MockConfig { Text = seString };
|
||||
PluginConfigurations.SerializeConfig(config);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void TestConfigDeserializable()
|
||||
{
|
||||
var builder = new SeStringBuilder();
|
||||
var seString = builder.AddText("Some text").Build();
|
||||
var config = new MockConfig { Text = seString };
|
||||
|
||||
|
||||
// This relies on the type information being maintained, which is why we're using these
|
||||
// static methods instead of default serialization/deserialization.
|
||||
var configSerialized = PluginConfigurations.SerializeConfig(config);
|
||||
var configDeserialized = (MockConfig)PluginConfigurations.DeserializeConfig(configSerialized);
|
||||
Assert.Equal(config, configDeserialized);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(49, 209)]
|
||||
[InlineData(71, 7)]
|
||||
[InlineData(62, 116)]
|
||||
public void TestAutoTranslatePayloadReencode(uint group, uint key)
|
||||
{
|
||||
var payload = new AutoTranslatePayload(group, key);
|
||||
|
||||
Assert.Equal(group, payload.Group);
|
||||
Assert.Equal(key, payload.Key);
|
||||
|
||||
var encoded = payload.Encode();
|
||||
using var stream = new MemoryStream(encoded);
|
||||
using var reader = new BinaryReader(stream);
|
||||
var decodedPayload = Payload.Decode(reader) as AutoTranslatePayload;
|
||||
|
||||
Assert.Equal(group, decodedPayload.Group);
|
||||
Assert.Equal(key, decodedPayload.Key);
|
||||
|
||||
Assert.Equal(payload.Group, decodedPayload.Group);
|
||||
Assert.Equal(payload.Key, decodedPayload.Key);
|
||||
|
||||
Assert.Equal(encoded, decodedPayload.Encode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue