public async Task CanSerializeAnObjectAsync() { using var memoryStream = new MemoryStream(); var o = new ExtendedModel(readOnlyD: 4) { A = "1", B = 2, C = 3, IgnoredE = 5, F = 6, }; await _jsonObjectSerializer.SerializeAsync(memoryStream, o, o.GetType(), default); Assert.AreEqual($"{{\"d\":4,\"{SerializedName("A")}\":\"1\",\"{SerializedName("B")}\":2}}", Encoding.UTF8.GetString(memoryStream.ToArray())); }
public async Task CanSerializeAnObjectAsync() { using var memoryStream = new MemoryStream(); var o = new ExtendedModel(4, 8) { A = "1", ActuallyB = 2, C = 3, Type = ModelType.One, IgnoredE = 5, F = 6, G = 7, }; await _jsonObjectSerializer.SerializeAsync(memoryStream, o, o.GetType(), default); Assert.AreEqual($"{{\"{SerializedName("A")}\":\"1\",\"b\":2,\"d\":4,\"{SerializedName("F")}\":6,\"h\":8,\"{SerializedName("Type")}\":\"one\"}}", Encoding.UTF8.GetString(memoryStream.ToArray())); }