Ejemplo n.º 1
0
        public void TestEnumGeneration()
        {
            // arrange
            var draftEnumMember = new TypeScriptEnumMember {
                Name = "Draft"
            };
            var finalEnumMember = new TypeScriptEnumMember {
                Name = "Final"
            };
            var typeScriptEnum = new TypeScriptEnum
            {
                Name    = "BillStatus",
                Members = new List <TypeScriptEnumMember> {
                    draftEnumMember, finalEnumMember
                }
            };
            var output             = new StringWriter();
            var expectOutputWriter = new StringWriter();

            expectOutputWriter.WriteLine("enum BillStatus {");
            draftEnumMember.Generate(expectOutputWriter, false);
            finalEnumMember.Generate(expectOutputWriter, true);
            expectOutputWriter.WriteLine("}");

            // act
            typeScriptEnum.Generate(output);

            // assert
            Assert.Equal(expectOutputWriter.GetStringBuilder().ToString(), output.GetStringBuilder().ToString());
        }
Ejemplo n.º 2
0
        public void TestEnumMemberWithValueIsLastMember()
        {
            // arrange
            var typeScriptEnumMember = new TypeScriptEnumMember {
                Name = "None", Value = 0
            };
            var output   = new StringWriter();
            var expected = "  None = 0" + Environment.NewLine;

            // act
            typeScriptEnumMember.Generate(output, isLastOne: true);

            // assert
            Assert.Equal(expected, output.GetStringBuilder().ToString());
        }