Exemplo n.º 1
0
        public void WriteWritesValueFromAttribute()
        {
            var c = new EnumSnakeCaseConverterInner <Cartoon>();

            using (var ms = new MemoryStream()) {
                using (var writer = new Utf8JsonWriter(ms)) {
                    c.Write(writer, Cartoon.BojackHorseman, null !);

                    writer.Flush();

                    var output = Encoding.UTF8.GetString(ms.ToArray());

                    Assert.AreEqual("\"that_horse_from_horsin_around\"", output);
                }
            }
        }
Exemplo n.º 2
0
        public void WriteWritesEnumValueAsSnakeCase()
        {
            var c = new EnumSnakeCaseConverterInner <Cartoon>();

            using (var ms = new MemoryStream()) {
                using (var writer = new Utf8JsonWriter(ms)) {
                    c.Write(writer, Cartoon.CatDog, null !);

                    writer.Flush();

                    var output = Encoding.UTF8.GetString(ms.ToArray());

                    Assert.AreEqual("\"cat_dog\"", output);
                }
            }
        }