public void LongMembers() { object obj = new LongMembers(); var str = new TestCSharpObjectFormatter(maximumLineLength: 20).FormatObject(obj, SingleLineOptions); Assert.Equal("LongMembers { LongNa...", str); str = new TestCSharpObjectFormatter(maximumLineLength: 20).FormatObject(obj, SeparateLinesOptions); Assert.Equal($"LongMembers {{{Environment.NewLine} LongName0123456789...{Environment.NewLine} LongValue: \"012345...{Environment.NewLine}}}{Environment.NewLine}", str); }
public void ValidNumberRadix() { var formatter = new TestCSharpObjectFormatter(includeCodePoints: true); var options = new PrintOptions(); options.NumberRadix = 10; Assert.Equal("10", formatter.FormatObject(10, options)); Assert.Equal("int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }", formatter.FormatObject(new int[10], options)); Assert.Equal(@"16 '\u0010'", formatter.FormatObject('\u0010', options)); options.NumberRadix = 16; Assert.Equal("0x0000000a", formatter.FormatObject(10, options)); Assert.Equal("int[0x0000000a] { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 }", formatter.FormatObject(new int[10], options)); Assert.Equal(@"0x0010 '\u0010'", formatter.FormatObject('\u0010', options)); }
public void Objects() { string str; object nested = new Outer.Nested <int>(); str = s_formatter.FormatObject(nested, SingleLineOptions); Assert.Equal(@"Outer.Nested<int> { A=1, B=2 }", str); str = s_formatter.FormatObject(nested, HiddenOptions); Assert.Equal(@"Outer.Nested<int>", str); str = s_formatter.FormatObject(A <int> .X, HiddenOptions); Assert.Equal(@"A<int>.B<int>", str); object obj = new A <int> .B <bool> .C.D <string, double> .E(); str = s_formatter.FormatObject(obj, HiddenOptions); Assert.Equal(@"A<int>.B<bool>.C.D<string, double>.E", str); var sort = new Sort(); str = new TestCSharpObjectFormatter(maximumLineLength: 51).FormatObject(sort, SingleLineOptions); Assert.Equal(@"Sort { aB=-1, ab=1, Ac=-1, Ad=1, ad=-1, aE=1, aF=-1...", str); Assert.Equal(51 + 3, str.Length); str = new TestCSharpObjectFormatter(maximumLineLength: 5).FormatObject(sort, SingleLineOptions); Assert.Equal(@"Sort ...", str); Assert.Equal(5 + 3, str.Length); str = new TestCSharpObjectFormatter(maximumLineLength: 4).FormatObject(sort, SingleLineOptions); Assert.Equal(@"Sort...", str); str = new TestCSharpObjectFormatter(maximumLineLength: 3).FormatObject(sort, SingleLineOptions); Assert.Equal(@"Sor...", str); str = new TestCSharpObjectFormatter(maximumLineLength: 2).FormatObject(sort, SingleLineOptions); Assert.Equal(@"So...", str); str = new TestCSharpObjectFormatter(maximumLineLength: 1).FormatObject(sort, SingleLineOptions); Assert.Equal(@"S...", str); str = new TestCSharpObjectFormatter(maximumLineLength: 80).FormatObject(sort, SingleLineOptions); Assert.Equal(@"Sort { aB=-1, ab=1, Ac=-1, Ad=1, ad=-1, aE=1, aF=-1, AG=1 }", str); }