Ejemplo n.º 1
0
        public void ShouldFilterAssertionLibraryImplementationDetails()
        {
            var primaryException    = GetNestedException();
            var secondaryExceptionA = new NotImplementedException();
            var secondaryExceptionB = GetSecondaryNestedException();

            assertionLibrary
            .Namespace("Fixie.Tests.Results")
            .Namespace("System");

            var exceptionInfo = new ExceptionInfo(new[] { primaryException, secondaryExceptionA, secondaryExceptionB }, assertionLibrary);

            exceptionInfo.DisplayName.ShouldEqual("");
            exceptionInfo.Type.ShouldEqual("System.NullReferenceException");
            exceptionInfo.Message.ShouldEqual("Null reference!");
            exceptionInfo.StackTrace
            .Split(new[] { Environment.NewLine }, StringSplitOptions.None)
            .Select(x => Regex.Replace(x, @":line \d+", ":line #"))     //Avoid brittle assertion introduced by stack trace line numbers.
            .ShouldEqual(
                "Null reference!",
                "",
                "",
                "------- Inner Exception: System.DivideByZeroException -------",
                "Divide by zero!",
                "",
                "",
                "===== Secondary Exception: System.NotImplementedException =====",
                "The method or operation is not implemented.",
                "",
                "",
                "===== Secondary Exception: System.ArgumentException =====",
                "Argument!",
                "",
                "",
                "------- Inner Exception: System.ApplicationException -------",
                "Application!",
                "",
                "",
                "------- Inner Exception: System.NotImplementedException -------",
                "Not implemented!",
                "");

            exceptionInfo.InnerException.ShouldBeNull();
        }