microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Tests/Microsoft.Teams.Common.Tests/StringEnumTests.cs
23lines · modecode
| 1 | using System.Text.Json; |
| 2 | |
| 3 | namespace Microsoft.Teams.Common.Tests; |
| 4 | |
| 5 | public class StringEnumTests |
| 6 | { |
| 7 | [Fact] |
| 8 | public void JsonSerialize() |
| 9 | { |
| 10 | var value = new StringEnum("test"); |
| 11 | var json = JsonSerializer.Serialize(value); |
| 12 | |
| 13 | Assert.Equal("\"test\"", json); |
| 14 | |
| 15 | var obj = new Dictionary<string, object>() |
| 16 | { |
| 17 | { "hello", new StringEnum("world") } |
| 18 | }; |
| 19 | |
| 20 | json = JsonSerializer.Serialize(obj); |
| 21 | Assert.Equal("{\"hello\":\"world\"}", json); |
| 22 | } |
| 23 | } |