public void Enumerable_OverLimit() { var limit = 10; var enumerable = Enumerable.Range(1, limit + 1); var result = new ObjectFormatter { AllowPotentialSideEffects = true, ListCountLimit = limit }.Format(enumerable); Assert.AreEqual(string.Join(", ", enumerable.Take(limit)) + ", …", result); }
private static string Describe(object result) { if (result == null) return "null: Null"; var typeString = typeFormatter.Format(result.GetType()); var valueString = new ObjectFormatter { AllowPotentialSideEffects = true }.Format(result); return valueString + ": " + typeString; }
public void StaticDelegate() { var result = new ObjectFormatter().Format((Func<double, TimeSpan>)(TimeSpan.FromMinutes)); Assert.AreEqual("<function:TimeSpan.FromMinutes>", result); }
public void Enumerable() { var enumerable = new[] { 6, 5, 4, 3, 2, 1 }.OrderBy(x => x); var result = new ObjectFormatter { AllowPotentialSideEffects = true }.Format(enumerable); Assert.AreEqual("(1, 2, 3, 4, 5, …)", result); }
public void Booleans(bool value, string expectedResult) { var result = new ObjectFormatter().Format(value); Assert.AreEqual(expectedResult, result); }
public void Arrays(object array, string expectedResult) { var result = new ObjectFormatter().Format(array); Assert.AreEqual(expectedResult, result); }
public void Range() { var range = new Range<int>(0, 10, System.Linq.Enumerable.Range(0, 11)); var result = new ObjectFormatter().Format(range); Assert.AreEqual("0..10", result); }