Exemple #1
0
        public void Test_Dump_Null許容型()
        {
            int?v = 1;

            Assert.AreEqual("1 (System.Int32)", Dumper.DumpToString(v));

            int?v2 = null;

            Assert.AreEqual("(null)", Dumper.DumpToString(v2));
        }
Exemple #2
0
        public void Test_Dump_例外()
        {
            var err = new ErrorClass();

            Assert.AreEqual(
                @"DebugLibTest.ErrorClass (DebugLibTest.ErrorClass)
{
    Error = 呼び出しのターゲットが例外をスローしました。
}
",
                Dumper.DumpToString(err));
        }
Exemple #3
0
 public void Test_Dump_プリミティブ()
 {
     Assert.AreEqual("(null)", Dumper.DumpToString(null));
     Assert.AreEqual("1 (System.Int32)", Dumper.DumpToString(1));
     Assert.AreEqual("10 (System.Int64)", Dumper.DumpToString(10L));
     Assert.AreEqual("79228162514264337593543950335 (System.Decimal)", Dumper.DumpToString(Decimal.MaxValue));
     Assert.AreEqual("0.12 (System.Double)", Dumper.DumpToString(0.12));
     Assert.AreEqual("0.1 (System.Single)", Dumper.DumpToString(0.1f));
     Assert.AreEqual("'A' (System.Char)", Dumper.DumpToString('A'));
     Assert.AreEqual("\"str\" (System.String)", Dumper.DumpToString("str"));
     Assert.AreEqual("\"1\\n2\\r3\" (System.String)", Dumper.DumpToString("1\n2\r3"));
 }
Exemple #4
0
        public void Test_Dump_クラス()
        {
            var test = new TestClass()
            {
                Number = 1
            };

            Assert.AreEqual(@"DebugLibTest.TestClass (DebugLibTest.TestClass)
{
    Number = 1 (System.Int32)
}
", Dumper.DumpToString(test));

            // 空クラス
            var empty = new EmptyClass();

            Assert.AreEqual(@"DebugLibTest.EmptyClass (DebugLibTest.EmptyClass)
{
}
", Dumper.DumpToString(empty));

            // ネストクラス
            var nest = new NestClass()
            {
                Child = new NestClass()
            };

            Assert.AreEqual(@"DebugLibTest.NestClass (DebugLibTest.NestClass)
{
    Child = DebugLibTest.NestClass (DebugLibTest.NestClass)
    {
        Child = (null)
    }
}
", Dumper.DumpToString(nest));

            // 循環参照
            var loop = new NestClass();

            loop.Child = loop;
            Assert.AreEqual(
                @"DebugLibTest.NestClass (DebugLibTest.NestClass)
{
    Child = DebugLibTest.NestClass (DebugLibTest.NestClass)<LoopReference>
}
",
                Dumper.DumpToString(loop));
        }
Exemple #5
0
 public void Test_Dump_Enum()
 {
     Assert.AreEqual("Apple (DebugLibTest.TestEnum)", Dumper.DumpToString(TestEnum.Apple));
     Assert.AreEqual("Apple, Google (DebugLibTest.TestEnum)", Dumper.DumpToString(TestEnum.Apple | TestEnum.Google));
 }
Exemple #6
0
        public void Test_Dump_コレクション()
        {
            // List<T>
            var listGeneric = new List <int> {
                1, 2
            };

            Assert.AreEqual(@"System.Collections.Generic.List`1[System.Int32] (System.Collections.Generic.List`1[System.Int32])
{
    [0] 1 (System.Int32)
    [1] 2 (System.Int32)
}
", Dumper.DumpToString(listGeneric));

            // ArrayList
            var list = new ArrayList {
                1, "text"
            };

            Assert.AreEqual(@"System.Collections.ArrayList (System.Collections.ArrayList)
{
    [0] 1 (System.Int32)
    [1] ""text"" (System.String)
}
", Dumper.DumpToString(list));

            // 空のコレクション
            var emptyList = new List <int> {
            };

            Assert.AreEqual(@"System.Collections.Generic.List`1[System.Int32] (System.Collections.Generic.List`1[System.Int32])
{
}
", Dumper.DumpToString(emptyList));

            // 2重コレクション
            var doubleList = new List <IList>
            {
                new List <int> {
                    1, 2
                },
                new List <long> {
                    11, 22
                },
            };

            Assert.AreEqual(@"System.Collections.Generic.List`1[System.Collections.IList] (System.Collections.Generic.List`1[System.Collections.IList])
{
    [0] System.Collections.Generic.List`1[System.Int32] (System.Collections.Generic.List`1[System.Int32])
    {
        [0] 1 (System.Int32)
        [1] 2 (System.Int32)
    }
    [1] System.Collections.Generic.List`1[System.Int64] (System.Collections.Generic.List`1[System.Int64])
    {
        [0] 11 (System.Int64)
        [1] 22 (System.Int64)
    }
}
", Dumper.DumpToString(doubleList));

            var classList = new List <TestClass>
            {
                new TestClass()
                {
                    Number = 1
                },
                new TestClass()
                {
                    Number = 2
                }
            };

            Assert.AreEqual(@"System.Collections.Generic.List`1[DebugLibTest.TestClass] (System.Collections.Generic.List`1[DebugLibTest.TestClass])
{
    [0] DebugLibTest.TestClass (DebugLibTest.TestClass)
    {
        Number = 1 (System.Int32)
    }
    [1] DebugLibTest.TestClass (DebugLibTest.TestClass)
    {
        Number = 2 (System.Int32)
    }
}
", classList.DumpToString());

            var classArray = new TestClass[]
            {
                new TestClass()
                {
                    Number = 1
                },
                new TestClass()
                {
                    Number = 2
                }
            };

            Assert.AreEqual(
                @"DebugLibTest.TestClass[] (DebugLibTest.TestClass[])
{
    [0] DebugLibTest.TestClass (DebugLibTest.TestClass)
    {
        Number = 1 (System.Int32)
    }
    [1] DebugLibTest.TestClass (DebugLibTest.TestClass)
    {
        Number = 2 (System.Int32)
    }
}
", classArray.DumpToString());
        }