Beispiel #1
0
        public void TestGenerateClassWithMembers()
        {
            // arrange
            var idMember = new TypeScriptClassMember {
                Name = "id", Type = "number"
            };
            var descriptionMembers = new TypeScriptClassMember {
                Name = "description", Type = "string"
            };
            var typeScriptClass = new TypeScriptClass {
                Name = "Blog", Members = new List <TypeScriptClassMember> {
                    idMember, descriptionMembers
                }
            };
            var output = new StringWriter();
            var expectedOutputWriter = new StringWriter();

            expectedOutputWriter.Write("class Blog {" + Environment.NewLine);
            idMember.Generate(expectedOutputWriter);
            descriptionMembers.Generate(expectedOutputWriter);
            expectedOutputWriter.Write("}" + Environment.NewLine);

            // act
            typeScriptClass.Generate(output);

            // assert
            var generatedOutput = output.GetStringBuilder().ToString();

            Assert.Equal(expectedOutputWriter.GetStringBuilder().ToString(), generatedOutput);
        }
Beispiel #2
0
        public void TestGenerate()
        {
            // arrange
            var classMember = new TypeScriptClassMember {
                Name = "id", Type = "number"
            };
            var output         = new StringWriter();
            var expectedOutput = "  id : number;" + Environment.NewLine;

            // act
            classMember.Generate(output);

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