示例#1
0
        public void CanHandle()
        {
            // arrange
            var sb     = new StringBuilder();
            var writer = new CodeWriter(sb);

            var generator = new EnumValueSerializerGenerator();

            var descriptor = new EnumValueSerializerDescriptor(
                "EpisodeValueSerializer",
                "Episode",
                "global::Demo.Episode",
                new []
            {
                new EnumElementDescriptor("NewHope", "NEWHOPE"),
                new EnumElementDescriptor("Empire", "EMPIRE"),
            }
                );

            // act
            bool result = generator.CanHandle(descriptor);

            // assert
            Assert.True(result);
        }
示例#2
0
        public async Task Generate_With_Value()
        {
            // arrange
            var sb     = new StringBuilder();
            var writer = new CodeWriter(sb);

            var generator = new EnumValueSerializerGenerator();

            var descriptor = new EnumValueSerializerDescriptor(
                "EpisodeValueSerializer",
                "Episode",
                "global::Demo.Episode",
                new []
            {
                new EnumElementDescriptor("NewHope", "NEWHOPE"),
                new EnumElementDescriptor("Empire", "EMPIRE"),
            }
                );

            // act
            await generator.WriteAsync(writer, descriptor);

            // assert
            sb.ToString().MatchSnapshot();
        }