public void AppendToStringBuilderAsLineTest() { var bld = PreInputted.ToStringBuilder(); StringBuilder reset() { return(bld.Clear().Append(PreInputted)); } var array = ExpectedString.Split(' '); var expected = PreInputted + ExpectedString.Replace(' ', '\t') + Environment.NewLine; array.AppendToStringBuilderAsLine(reset(), '\t').Is(expected); array.AppendToStringBuilder(reset(), "hoge").Is(PreInputted + ExpectedString.Replace(" ", "hoge")); Array.Empty <string>().AppendToStringBuilderAsLine(reset(), '\t').Is(PreInputted + Environment.NewLine); Array.Empty <string>().AppendToStringBuilderAsLine(reset(), "hoge").Is(PreInputted + Environment.NewLine); var span = new ReadOnlySpan <string>(array); span.AppendToStringBuilderAsLine(reset(), '\t').Is(expected); span.AppendToStringBuilderAsLine(reset(), "hoge").Is(PreInputted + ExpectedString.Replace(" ", "hoge") + Environment.NewLine); span = new ReadOnlySpan <string>(Array.Empty <string>()); span.AppendToStringBuilderAsLine(reset(), '\t').Is(PreInputted + Environment.NewLine); span.AppendToStringBuilderAsLine(reset(), "hoge").Is(PreInputted + Environment.NewLine); var mem = new ReadOnlyMemory <string>(array); mem.AppendToStringBuilderAsLine(reset(), '\t').Is(expected); mem.AppendToStringBuilder(reset(), "hoge").Is(PreInputted + ExpectedString.Replace(" ", "hoge")); mem = new ReadOnlyMemory <string>(Array.Empty <string>()); mem.AppendToStringBuilderAsLine(reset(), '\t').Is(PreInputted + Environment.NewLine); mem.AppendToStringBuilderAsLine(reset(), "hoge").Is(PreInputted + Environment.NewLine); var seq = array.Select(s => s.ToCharArray().Select(c => c)); seq.AppendToStringBuilderAsLine(reset(), '\t').Is(expected); seq.AppendToStringBuilder(reset(), "hoge").Is(PreInputted + ExpectedString.Replace(" ", "hoge")); seq = Enumerable.Empty <string>(); seq.AppendToStringBuilderAsLine(reset(), '\t').Is(PreInputted + Environment.NewLine); seq.AppendToStringBuilderAsLine(reset(), "hoge").Is(PreInputted + Environment.NewLine); var strArray = Enumerable.Range(0, 10).Select(i => i.ToString()).ToArray(); strArray.AppendToStringBuilderAsLine(reset(), '\t') .Is(PreInputted + string.Join('\t', strArray) + Environment.NewLine); strArray.AppendToStringBuilderAsLine(reset(), "hoge") .Is(PreInputted + string.Join("hoge", strArray) + Environment.NewLine); object[] objArray = strArray; objArray.AppendToStringBuilderAsLine(reset(), '\t') .Is(PreInputted + string.Join('\t', objArray) + Environment.NewLine); objArray.AppendToStringBuilderAsLine(reset(), "hoge") .Is(PreInputted + string.Join("hoge", objArray) + Environment.NewLine); var intSeq = Enumerable.Range(0, 10); intSeq.AppendToStringBuilderAsLine(reset(), '\t') .Is(PreInputted + string.Join('\t', intSeq) + Environment.NewLine); intSeq.AppendToStringBuilderAsLine(reset(), "hoge") .Is(PreInputted + string.Join("hoge", intSeq) + Environment.NewLine); }