Exemplo n.º 1
0
        public void TestSingleException()
        {
            var dump   = new ExceptionDump(new Exception("hello world"));
            var actual = dump.ToString();
            var split  = actual.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.That(split, Is.EqualTo(new[] { "System.Exception", "hello world" }));
            Assert.That(split.Length, Is.EqualTo(2));
        }
Exemplo n.º 2
0
        public void TestDumpsStackTrace()
        {
            var ex     = BuildException();
            var dump   = new ExceptionDump(ex);
            var actual = dump.ToString();
            var split  = actual.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.That(split[1], Is.EqualTo("HI"));
            Assert.That(split[2], Is.StringContaining("at SupaCharge.UnitTests.Core.ExceptionHandling"));
            Assert.That(split.Length, Is.EqualTo(3));
        }
Exemplo n.º 3
0
        public void TestInnerExceptionDisplay()
        {
            var ex = new Exception("hi", new Exception("bye"));

            var dump   = new ExceptionDump(ex);
            var actual = dump.ToString();
            var split  = actual.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.That(split[0], Is.EqualTo("System.Exception"));
            Assert.That(split[1], Is.EqualTo("hi"));
            Assert.That(split[2], Is.EqualTo("----- Inner Exception"));
            Assert.That(split[3], Is.EqualTo("System.Exception"));
            Assert.That(split.Length, Is.EqualTo(5));
        }
Exemplo n.º 4
0
        public void TestLengthyChainOfExceptions()
        {
            var ex     = new Exception("hi", new Exception("bye", new Exception("Here", new Exception("yo", new Exception("last one")))));
            var dump   = new ExceptionDump(ex);
            var actual = dump.ToString();
            var split  = actual.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            Assert.That(split[0], Is.EqualTo("System.Exception"));
            Assert.That(split[1], Is.EqualTo("hi"));
            Assert.That(split[2], Is.EqualTo("----- Inner Exception"));
            Assert.That(split[3], Is.EqualTo("System.Exception"));
            Assert.That(split[4], Is.EqualTo("bye"));
            Assert.That(split[5], Is.EqualTo("----- Inner Exception"));
            Assert.That(split[6], Is.EqualTo("System.Exception"));
            Assert.That(split[7], Is.EqualTo("Here"));
            Assert.That(split[8], Is.EqualTo("----- Inner Exception"));
            Assert.That(split[9], Is.EqualTo("System.Exception"));
            Assert.That(split[10], Is.EqualTo("yo"));
            Assert.That(split[11], Is.EqualTo("----- Inner Exception"));
            Assert.That(split[12], Is.EqualTo("System.Exception"));
            Assert.That(split[13], Is.EqualTo("last one"));
        }