public static void DeserializeEnumWithDifferentCases() { EnumWithDifferentCases e = JsonSerializer.Deserialize <EnumWithDifferentCases>("0"); Assert.Equal(EnumWithDifferentCases.M, e); e = JsonSerializer.Deserialize <EnumWithDifferentCases>("1"); Assert.Equal(EnumWithDifferentCases.m, e); }
public void DeserializeEnumWithDifferentCases() { EnumWithDifferentCases e = JsonConvert.DeserializeObject <EnumWithDifferentCases>(@"""M""", new StringEnumConverter()); Assert.AreEqual(EnumWithDifferentCases.M, e); e = JsonConvert.DeserializeObject <EnumWithDifferentCases>(@"""m""", new StringEnumConverter()); Assert.AreEqual(EnumWithDifferentCases.m, e); }
public void DeserializeEnumWithDifferentCases() { EnumWithDifferentCases e = JsonConvert.DeserializeObject <EnumWithDifferentCases>(@"""M""", new StringEnumConverter()); Assert.AreEqual(EnumWithDifferentCases.M, e); e = JsonConvert.DeserializeObject <EnumWithDifferentCases>(@"""m""", new StringEnumConverter()); // unfortunatly Enum.Parse with ignoreCase will find the first match rather than the best match // it would be great to find a way around this Assert.AreEqual(EnumWithDifferentCases.M, e); }