Example #1
0
        public void NonXunitException()
        {
            var errorMetadata = new ErrorMetadata {
                new Exception("This is the message")
            };

            var result = ExceptionUtility.CombineMessages(errorMetadata);

            Assert.Equal("System.Exception : This is the message", result);
        }
Example #2
0
        public void NonXunitExceptionWithInnerExceptions()
        {
            var errorMetadata = new ErrorMetadata {
                { new Exception("outer exception"), -1 },
                { new DivideByZeroException("inner exception"), 0 },
                { new XunitException("inner inner exception"), 1 }
            };

            var result = ExceptionUtility.CombineMessages(errorMetadata);

            Assert.Equal(
                "System.Exception : outer exception" + Environment.NewLine +
                "---- System.DivideByZeroException : inner exception" + Environment.NewLine +
                "-------- inner inner exception",
                result
                );
        }
Example #3
0
        public void AggregateException()
        {
            var errorMetadata = new ErrorMetadata {
                { new AggregateException(), -1 },
                { new DivideByZeroException("inner #1"), 0 },
                { new NotImplementedException("inner #2"), 0 },
                { new XunitException("this is crazy"), 0 },
            };

            var result = ExceptionUtility.CombineMessages(errorMetadata);

            Assert.Equal(
                "System.AggregateException : One or more errors occurred." + Environment.NewLine +
                "---- System.DivideByZeroException : inner #1" + Environment.NewLine +
                "---- System.NotImplementedException : inner #2" + Environment.NewLine +
                "---- this is crazy",
                result
                );
        }
Example #4
0
        public void MissingExceptionTypes()
        {
            var errorMetadata = new ErrorMetadata();

            errorMetadata.AddMessage("Message 1");
            errorMetadata.AddMessage("Message 2");
            errorMetadata.AddMessage("Message 3");
            errorMetadata.AddIndex(-1);
            errorMetadata.AddIndex(0);
            errorMetadata.AddIndex(0);
            errorMetadata.AddExceptionType("ExceptionType1");
            errorMetadata.AddExceptionType("Xunit.Sdk.ExceptionType2");

            var result = ExceptionUtility.CombineMessages(errorMetadata);

            Assert.Equal(
                "ExceptionType1 : Message 1" + Environment.NewLine +
                "---- Message 2" + Environment.NewLine +
                "----  : Message 3",
                result
                );
        }