示例#1
0
        public static void FormatToConsole()
        {
            try
            {
                ExceptionExtensionsTests.Throw();
                Assert.Fail();
            }
            catch (NotImplementedException e)
            {
                var consoleOut = Console.Out;

                try
                {
                    using var writer = new StringWriter(CultureInfo.CurrentCulture);
                    Console.SetOut(writer);
                    e.Print();
                    var content = writer.GetStringBuilder().ToString();

                    Assert.Multiple(() =>
                    {
                        Assert.That(content, Contains.Substring("Type Name: System.NotImplementedException"));
                        Assert.That(content, Contains.Substring("Source: Spackle.Tests"));
                        Assert.That(content, Does.Not.Contain("Data:"));
                        Assert.That(content, Does.Not.Contain("Custom Properties:"));
                    });
                }
                finally
                {
                    Console.SetOut(consoleOut);
                }
            }
        }
示例#2
0
        public static void FormatWithMethodThatHasArguments()
        {
            try
            {
                ExceptionExtensionsTests.ThrowWithMethodThatHasArguments(1, new object());
                Assert.Fail();
            }
            catch (NotImplementedException e)
            {
                using var writer = new StringWriter(CultureInfo.CurrentCulture);
                e.Print(writer);
                var content = writer.GetStringBuilder().ToString();

                Assert.Multiple(() =>
                {
                    Assert.That(content, Contains.Substring("Type Name: System.NotImplementedException"));
                    Assert.That(content, Contains.Substring("Source: Spackle.Tests"));
                    Assert.That(content, Does.Not.Contain("Data:"));
                    Assert.That(content, Does.Not.Contain("Custom Properties:"));
                });
            }
        }
		private static void ThrowWithMethodThatHasArguments(int a, ExceptionExtensionsTests b)
		{
			throw new NotImplementedException();
		}