private string GetDisplayName(Element element) { var builder = new StringBuilder(128); builder.AppendFirst(element.Id, element.Name); builder.AppendIf(" -> ", builder.Length > 0); builder.Append(element.ApplicationId); return builder.ToString(); }
public void AppendIf() { // Type var @this = new StringBuilder(); // Exemples @this.AppendIf(x => x.Contains("F"), "Fizz", "Buzz"); // return "FizzBuzz"; // Unit Test Assert.AreEqual("Fizz", @this.ToString()); }
public void AppendIf_False() { var sb = new StringBuilder(); sb.AppendIf(false, "ab"); sb.ToString().Should().BeEmpty(); }
public void AppendIf_True() { var sb = new StringBuilder(); sb.AppendIf(true, "ab"); sb.ToString().Should().Be("ab"); }