1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-10-19 05:06:10 +00:00
X10D/X10D.Tests/src/Text/StringTests.cs

30 lines
828 B
C#
Raw Normal View History

2022-04-22 08:42:37 +00:00
using System.Text.Json.Serialization;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using X10D.Text;
namespace X10D.Tests.Text;
[TestClass]
public class StringTests
{
private struct SampleStructure
{
[JsonPropertyName("values")]
public int[] Values { get; set; }
}
[TestMethod]
public void FromJsonShouldDeserializeCorrectly()
{
const string json = "{\"values\": [1, 2, 3]}";
var target = json.FromJson<SampleStructure>();
Assert.IsInstanceOfType(target, typeof(SampleStructure));
Assert.IsNotNull(target);
Assert.IsNotNull(target.Values);
Assert.AreEqual(3, target.Values.Length);
Assert.AreEqual(1, target.Values[0]);
Assert.AreEqual(2, target.Values[1]);
Assert.AreEqual(3, target.Values[2]);
}
}