-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EnableDisplayInnerException for ScriptRuntimeException
- Loading branch information
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
using Scriban.Parsing; | ||
using Scriban.Runtime; | ||
using Scriban.Syntax; | ||
using NSubstitute; | ||
|
||
namespace Scriban.Tests | ||
{ | ||
public class ScriptRuntimeExceptionTests | ||
{ | ||
[Test] | ||
public void TestInnerExceptionExists() | ||
{ | ||
ScriptRuntimeException.EnableDisplayInnerException = true; | ||
SourceSpan testSourcespanObject = new SourceSpan("fileName", new TextPosition(0, 0, 0), new TextPosition(0, 0, 0)); | ||
Exception exception = Substitute.For<Exception>(); | ||
exception.StackTrace.Returns("TestStacTrace"); | ||
exception.Message.Returns("Test RunTime message"); | ||
|
||
ScriptRuntimeException testScriptruntimeObject = new ScriptRuntimeException(testSourcespanObject, "Any string", exception); | ||
|
||
Assert.True(testScriptruntimeObject.ToString().Contains("TestStacTrace")); | ||
Assert.True(testScriptruntimeObject.ToString().Contains("Test RunTime message")); | ||
} | ||
|
||
[Test] | ||
public void TestInnerExceptiondosentExists() | ||
{ | ||
ScriptRuntimeException.EnableDisplayInnerException = true; | ||
SourceSpan testSourcespanObject = new SourceSpan("fileName", new TextPosition(0, 0, 0), new TextPosition(0, 0, 0)); | ||
|
||
ScriptRuntimeException testScriptruntimeObject = new ScriptRuntimeException(testSourcespanObject, "Any string"); | ||
|
||
Assert.AreEqual(testScriptruntimeObject.ToString(), testScriptruntimeObject.Message); | ||
} | ||
|
||
[Test] | ||
public void TestInnerExceptionDisabled() | ||
{ | ||
ScriptRuntimeException.EnableDisplayInnerException = false; | ||
SourceSpan testSourcespanObject = new SourceSpan("fileName", new TextPosition(0, 0, 0), new TextPosition(0, 0, 0)); | ||
Exception exception = Substitute.For<Exception>(); | ||
exception.StackTrace.Returns("TestStacTrace"); | ||
exception.Message.Returns("Test RunTime message"); | ||
|
||
ScriptRuntimeException testScriptruntimeObject = new ScriptRuntimeException(testSourcespanObject, "Any string", exception); | ||
|
||
Assert.AreEqual(testScriptruntimeObject.ToString(), testScriptruntimeObject.Message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters