示例#1
0
 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);
 }
示例#2
0
文件: Program.cs 项目: ashmind/light
        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;
        }
示例#3
0
 public void StaticDelegate()
 {
     var result = new ObjectFormatter().Format((Func<double, TimeSpan>)(TimeSpan.FromMinutes));
     Assert.AreEqual("<function:TimeSpan.FromMinutes>", result);
 }
示例#4
0
 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);
 }
示例#5
0
 public void Booleans(bool value, string expectedResult)
 {
     var result = new ObjectFormatter().Format(value);
     Assert.AreEqual(expectedResult, result);
 }
示例#6
0
 public void Arrays(object array, string expectedResult)
 {
     var result = new ObjectFormatter().Format(array);
     Assert.AreEqual(expectedResult, result);
 }
示例#7
0
 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);
 }