public void TestEnumGeneration() { // arrange var draftEnumMember = new CSharpEnumMember { Name = "Draft" }; var finalEnumMember = new CSharpEnumMember { Name = "Final" }; var csharpEnum = new CSharpEnum { Name = "BillStatus", Members = new List <CSharpEnumMember> { draftEnumMember, finalEnumMember } }; var output = new StringWriter(); var expectOutputWriter = new StringWriter(); expectOutputWriter.WriteLine(" public enum BillStatus"); expectOutputWriter.WriteLine(" {"); draftEnumMember.Generate(expectOutputWriter, false); finalEnumMember.Generate(expectOutputWriter, true); expectOutputWriter.WriteLine(" }"); // act csharpEnum.Generate(output); // assert Assert.Equal(expectOutputWriter.GetStringBuilder().ToString(), output.GetStringBuilder().ToString()); }
public void TestEnumMemberWithValueIsLastMember() { // arrange var csharpEnumMember = new CSharpEnumMember { Name = "None", Value = 0 }; var output = new StringWriter(); var expected = " None = 0" + Environment.NewLine; // act csharpEnumMember.Generate(output, isLastOne: true); // assert Assert.Equal(expected, output.GetStringBuilder().ToString()); }