From 03835aebc0e156dfc50330ed88749f37db16d8c9 Mon Sep 17 00:00:00 2001 From: Sergey Lanzman Date: Tue, 22 Jun 2021 20:20:18 +0300 Subject: [PATCH 1/2] Update README.md (#9) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6daa7bb..802e5a1 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ TypeError: Cannot read property 'length' of undefined The top level API for call stack deminification is the `StackTraceDeminifier.DeminifyStackTrace` method. For each url that appears in a JavaScript callstack, the library requires the contents of the JavaScript file and corresponding source map in order to determine the original method name and code location. This information is provided by the consumer of the API by implementing the `ISourceMapProvider` and `ISourceCodeProvider` interfaces. These interfaces are expected to return a `Stream` that can be used to access the contents of the requested JavaScript code or corresponding source map. A `StackTraceDeminifier` can be instantiated using one of the methods on `StackTraceDeminfierFactory`. A sample usage of the library is shown below. ```csharp -StackTraceDeminifier sourceMapCallstackDeminifier = StackTraceDeminfierFactory.GetStackTraceDeminfier(new SourceMapProvider(), new SourceCodeProvider()); +StackTraceDeminifier sourceMapCallstackDeminifier = StackTraceDeminifierFactory.GetStackTraceDeminfier(new SourceMapProvider(), new SourceCodeProvider()); DeminifyStackTraceResult deminifyStackTraceResult = sourceMapCallstackDeminifier.DeminifyStackTrace(callstack); string deminifiedCallstack = deminifyStackTraceResult.ToString(); ``` From 6697ae937e782c54837955b3f9ffdf090749f9ff Mon Sep 17 00:00:00 2001 From: MaceWindu Date: Wed, 30 Jun 2021 17:19:58 +0200 Subject: [PATCH 2/2] Changes for 1.0 final release (#10) * changes for 1.0 final release * set package version * revert unwanted change * remove debug file --- Directory.Packages.props | 11 + Shared.props | 2 + SourcemapTools.sln | 1 + ci/default.yml | 2 +- .../CallstackDeminifier/AllAstVisitor.cs | 15 +- .../StackFrameDeminifier.cs | 5 - .../CallstackDeminifier/StackTraceParser.cs | 10 - .../SourcemapParser/MappingEntry.cs | 5 +- .../SourcemapParser/SourceMap.cs | 5 - .../SourcemapParser/SourceMapGenerator.cs | 5 - src/SourceMapTools/SourcemapTools.csproj | 6 +- .../FunctionMapConsumerUnitTests.cs | 18 +- .../FunctionMapGeneratorUnitTests.cs | 400 +++++++++--------- .../KeyValueCacheUnitTests.cs | 16 +- .../SourceMapExtensionsUnitTests.cs | 18 +- .../StackFrameDeminifierUnitTests.cs | 62 ++- ...tackTraceDeminifierClosureEndToEndTests.cs | 22 +- .../StackTraceDeminifierEndToEndTests.cs | 31 +- ...tackTraceDeminifierMapOnlyEndToEndTests.cs | 30 +- .../StackTraceDeminifierUnitTests.cs | 14 +- ...tackTraceDeminifierWebpackEndToEndTests.cs | 6 +- .../StackTraceParserUnitTests.cs | 124 +++--- .../Base64ConverterUnitTests.cs | 20 +- .../Base64VlqDecoderUnitTests.cs | 15 +- .../Base64VlqEncoderUnitTests.cs | 14 +- .../IReadOnlyListExtensionsUnitTests.cs | 26 +- .../MappingsListParserUnitTests.cs | 78 ++-- .../NumericMappingEntryUnitTests.cs | 32 +- .../SourceMapGeneratorUnitTests.cs | 44 +- .../SourceMapParserUnitTests.cs | 22 +- .../SourceMapTransformerUnitTests.cs | 50 +-- .../SourcemapParser/SourceMapUnitTests.cs | 66 +-- .../SourcePositionUnitTests.cs | 44 +- .../StringExtensionsUnitTests.cs | 67 ++- .../SourcemapTools.UnitTests.csproj | 8 +- 35 files changed, 602 insertions(+), 692 deletions(-) create mode 100644 Directory.Packages.props diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..3289680 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Shared.props b/Shared.props index cc65794..f8f6fa9 100644 --- a/Shared.props +++ b/Shared.props @@ -29,5 +29,7 @@ preview true true + + true \ No newline at end of file diff --git a/SourcemapTools.sln b/SourcemapTools.sln index 19e3686..914f45a 100644 --- a/SourcemapTools.sln +++ b/SourcemapTools.sln @@ -13,6 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "root", "root", "{38BD9C43-B .gitattributes = .gitattributes .gitignore = .gitignore CONTRIBUTING.md = CONTRIBUTING.md + Directory.Packages.props = Directory.Packages.props LICENSE.txt = LICENSE.txt Package.nuspec = Package.nuspec README.md = README.md diff --git a/ci/default.yml b/ci/default.yml index 63f9717..a52d670 100644 --- a/ci/default.yml +++ b/ci/default.yml @@ -6,7 +6,7 @@ variables: - name: assemblyVersion value: 1.0.0 - name: packageVersion - value: 1.0.0-rc.3 + value: 1.0.0 - name: nugetDevVersion value: 1.0.0 diff --git a/src/SourceMapTools/CallstackDeminifier/AllAstVisitor.cs b/src/SourceMapTools/CallstackDeminifier/AllAstVisitor.cs index 16ca9f6..ecb0c69 100644 --- a/src/SourceMapTools/CallstackDeminifier/AllAstVisitor.cs +++ b/src/SourceMapTools/CallstackDeminifier/AllAstVisitor.cs @@ -11,7 +11,7 @@ namespace SourcemapToolkit.CallstackDeminifier // should be removed if https://github.com/sebastienros/esprima-dotnet/pull/148 accepted internal class AllAstVisitor { - private readonly List _parentStack = new List(); + private readonly List _parentStack = new (); protected IReadOnlyList ParentStack => _parentStack; /// @@ -240,6 +240,9 @@ public virtual void Visit(Node node) case Nodes.ClassExpression: VisitClassExpression(node.As()); break; + case Nodes.ChainExpression: + VisitChainExpression(node.As()); + break; default: VisitUnknownNode(node); break; @@ -248,6 +251,11 @@ public virtual void Visit(Node node) _parentStack.RemoveAt(_parentStack.Count - 1); } + protected virtual void VisitChainExpression(ChainExpression chainExpression) + { + Visit(chainExpression.Expression); + } + protected virtual void VisitProgram(Program program) { VisitNodeList(program.Body); @@ -260,7 +268,10 @@ protected virtual void VisitUnknownNode(Node node) protected virtual void VisitCatchClause(CatchClause catchClause) { - Visit(catchClause.Param); + if (catchClause.Param != null) + { + Visit(catchClause.Param); + } Visit(catchClause.Body); } diff --git a/src/SourceMapTools/CallstackDeminifier/StackFrameDeminifier.cs b/src/SourceMapTools/CallstackDeminifier/StackFrameDeminifier.cs index 9c49851..fbab2e1 100644 --- a/src/SourceMapTools/CallstackDeminifier/StackFrameDeminifier.cs +++ b/src/SourceMapTools/CallstackDeminifier/StackFrameDeminifier.cs @@ -29,11 +29,6 @@ public StackFrameDeminifier(ISourceMapStore sourceMapStore, IFunctionMapStore fu /// Returns a StackFrameDeminificationResult that contains a stack trace that has been translated to the original source code. The DeminificationError Property indicates if the StackFrame could not be deminified. DeminifiedStackFrame will not be null, but any properties of DeminifiedStackFrame could be null if the value could not be extracted. StackFrameDeminificationResult IStackFrameDeminifier.DeminifyStackFrame(StackFrame stackFrame, string? callerSymbolName) { - if (stackFrame == null) - { - throw new ArgumentNullException(nameof(stackFrame)); - } - var sourceMap = _sourceMapStore.GetSourceMapForUrl(stackFrame.FilePath); var generatedSourcePosition = stackFrame.SourcePosition; diff --git a/src/SourceMapTools/CallstackDeminifier/StackTraceParser.cs b/src/SourceMapTools/CallstackDeminifier/StackTraceParser.cs index c926d20..5ddc26c 100644 --- a/src/SourceMapTools/CallstackDeminifier/StackTraceParser.cs +++ b/src/SourceMapTools/CallstackDeminifier/StackTraceParser.cs @@ -47,11 +47,6 @@ IReadOnlyList IStackTraceParser.ParseStackTrace(string stackTraceStr /// public virtual IReadOnlyList ParseStackTrace(string stackTraceString, out string? message) { - if (stackTraceString == null) - { - throw new ArgumentNullException(nameof(stackTraceString)); - } - message = null; var stackFrameStrings = stackTraceString.SplitFast('\n'); @@ -137,11 +132,6 @@ public virtual IReadOnlyList ParseStackTrace(string stackTraceString /// protected internal virtual StackFrame? TryParseSingleStackFrame(string frame) { - if (frame == null) - { - throw new ArgumentNullException(nameof(frame)); - } - var lineNumberMatch = _lineNumberRegex.Match(frame); if (!lineNumberMatch.Success) diff --git a/src/SourceMapTools/SourcemapParser/MappingEntry.cs b/src/SourceMapTools/SourcemapParser/MappingEntry.cs index 2ea107c..a4b7bf7 100644 --- a/src/SourceMapTools/SourcemapParser/MappingEntry.cs +++ b/src/SourceMapTools/SourcemapParser/MappingEntry.cs @@ -1,8 +1,11 @@ -namespace SourcemapToolkit.SourcemapParser +using System.Diagnostics; + +namespace SourcemapToolkit.SourcemapParser { /// /// Source map entry. /// + [DebuggerDisplay("(Column: {GeneratedSourcePosition.Column}, Line: {GeneratedSourcePosition.Line}): {OriginalName}")] public struct MappingEntry { /// diff --git a/src/SourceMapTools/SourcemapParser/SourceMap.cs b/src/SourceMapTools/SourcemapParser/SourceMap.cs index 836fe2c..a612b16 100644 --- a/src/SourceMapTools/SourcemapParser/SourceMap.cs +++ b/src/SourceMapTools/SourcemapParser/SourceMap.cs @@ -114,11 +114,6 @@ public SourceMap Clone() /// public SourceMap ApplySourceMap(SourceMap submap, string? sourceFile = null) { - if (submap == null) - { - throw new ArgumentNullException(nameof(submap)); - } - if (sourceFile == null) { if (submap.File == null) diff --git a/src/SourceMapTools/SourcemapParser/SourceMapGenerator.cs b/src/SourceMapTools/SourcemapParser/SourceMapGenerator.cs index 19a4797..5785be7 100644 --- a/src/SourceMapTools/SourcemapParser/SourceMapGenerator.cs +++ b/src/SourceMapTools/SourcemapParser/SourceMapGenerator.cs @@ -29,11 +29,6 @@ public static string GenerateSourceMapInlineComment(SourceMap sourceMap, JsonSer /// public static string SerializeMapping(SourceMap sourceMap, JsonSerializerOptions? jsonSerializerSettings = null) { - if (sourceMap == null) - { - throw new ArgumentNullException(nameof(sourceMap)); - } - string? mappings = null; if (sourceMap.ParsedMappings.Count > 0) { diff --git a/src/SourceMapTools/SourcemapTools.csproj b/src/SourceMapTools/SourcemapTools.csproj index f06e96e..24287cc 100644 --- a/src/SourceMapTools/SourcemapTools.csproj +++ b/src/SourceMapTools/SourcemapTools.csproj @@ -6,10 +6,10 @@ - - + + - + all runtime; build; native; contentfiles; analyzers diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/FunctionMapConsumerUnitTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/FunctionMapConsumerUnitTests.cs index a15c742..83a7d7d 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/FunctionMapConsumerUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/FunctionMapConsumerUnitTests.cs @@ -1,13 +1,13 @@ using System.Collections.Generic; using SourcemapToolkit.SourcemapParser; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { public class FunctionMapConsumerUnitTests { - [Fact] + [Test] public void GetWrappingFunctionForSourceLocation_EmptyFunctionMap_ReturnNull() { // Arrange @@ -22,7 +22,7 @@ public void GetWrappingFunctionForSourceLocation_EmptyFunctionMap_ReturnNull() Assert.Null(wrappingFunction); } - [Fact] + [Test] public void GetWrappingFunctionForSourceLocation_SingleIrrelevantFunctionMapEntry_ReturnNull() { // Arrange @@ -44,7 +44,7 @@ public void GetWrappingFunctionForSourceLocation_SingleIrrelevantFunctionMapEntr Assert.Null(wrappingFunction); } - [Fact] + [Test] public void GetWrappingFunctionForSourceLocation_SingleRelevantFunctionMapEntry_ReturnWrappingFunction() { // Arrange @@ -65,10 +65,10 @@ public void GetWrappingFunctionForSourceLocation_SingleRelevantFunctionMapEntry_ var wrappingFunction = functionMapConsumer.GetWrappingFunctionForSourceLocation(sourcePosition, functionMap); // Assert - Assert.Equal(functionMapEntry, wrappingFunction); + Assert.AreEqual(functionMapEntry, wrappingFunction); } - [Fact] + [Test] public void GetWrappingFunctionForSourceLocation_MultipleFunctionMapEntriesSingleRelevantFunctionMapEntry_ReturnWrappingFunction() { // Arrange @@ -96,10 +96,10 @@ public void GetWrappingFunctionForSourceLocation_MultipleFunctionMapEntriesSingl var wrappingFunction = functionMapConsumer.GetWrappingFunctionForSourceLocation(sourcePosition, functionMap); // Assert - Assert.Equal(functionMapEntry2, wrappingFunction); + Assert.AreEqual(functionMapEntry2, wrappingFunction); } - [Fact] + [Test] public void GetWrappingFunctionForSourceLocation_MultipleFunctionMapEntriesMultipleRelevantFunctionMapEntry_ReturnClosestWrappingFunction() { // Arrange @@ -127,7 +127,7 @@ public void GetWrappingFunctionForSourceLocation_MultipleFunctionMapEntriesMulti var wrappingFunction = functionMapConsumer.GetWrappingFunctionForSourceLocation(sourcePosition, functionMap); // Assert - Assert.Equal(functionMapEntry2, wrappingFunction); + Assert.AreEqual(functionMapEntry2, wrappingFunction); } } } diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/FunctionMapGeneratorUnitTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/FunctionMapGeneratorUnitTests.cs index 4cec508..178bc26 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/FunctionMapGeneratorUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/FunctionMapGeneratorUnitTests.cs @@ -2,14 +2,14 @@ using System.Collections.Generic; using SourcemapToolkit.SourcemapParser; using SourcemapToolkit.SourcemapParser.UnitTests; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { public class FunctionMapGeneratorUnitTests { - [Fact] + [Test] public void GenerateFunctionMap_NullSourceMap_ReturnsNull() { // Arrange @@ -24,7 +24,7 @@ public void GenerateFunctionMap_NullSourceMap_ReturnsNull() } - [Fact] + [Test] public void ParseSourceCode_NoFunctionsInSource_EmptyFunctionList() { // Arrange @@ -34,10 +34,10 @@ public void ParseSourceCode_NoFunctionsInSource_EmptyFunctionList() var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Empty(functionMap); + Assert.AreEqual(0, functionMap.Count); } - [Fact] + [Test] public void ParseSourceCode_SingleLineFunctionInSource_CorrectZeroBasedColumnNumbers() { // Arrange @@ -47,17 +47,17 @@ public void ParseSourceCode_SingleLineFunctionInSource_CorrectZeroBasedColumnNum var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Single(functionMap); - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(9, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(14, functionMap[0].Start.Column); - Assert.Equal(22, functionMap[0].End.Column); + Assert.AreEqual(1, functionMap.Count); + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(9, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(14, functionMap[0].Start.Column); + Assert.AreEqual(22, functionMap[0].End.Column); } - [Fact] + [Test] public void ParseSourceCode_MultiLineFunctionInSource_CorrectColumnAndZeroBasedLineNumbers() { // Arrange @@ -68,17 +68,17 @@ public void ParseSourceCode_MultiLineFunctionInSource_CorrectColumnAndZeroBasedL var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Single(functionMap); - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(9, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(1, functionMap[0].Start.Line); - Assert.Equal(3, functionMap[0].End.Line); - Assert.Equal(0, functionMap[0].Start.Column); - Assert.Equal(1, functionMap[0].End.Column); + Assert.AreEqual(1, functionMap.Count); + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(9, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(1, functionMap[0].Start.Line); + Assert.AreEqual(3, functionMap[0].End.Line); + Assert.AreEqual(0, functionMap[0].Start.Column); + Assert.AreEqual(1, functionMap[0].End.Column); } - [Fact] + [Test] public void ParseSourceCode_TwoSingleLineFunctions_TwoFunctionMapEntries() { // Arrange @@ -88,26 +88,26 @@ public void ParseSourceCode_TwoSingleLineFunctions_TwoFunctionMapEntries() var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Equal(2, functionMap.Count); - - Assert.Equal("bar", functionMap[0].Bindings[0].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(31, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(36, functionMap[0].Start.Column); - Assert.Equal(44, functionMap[0].End.Column); - - Assert.Equal("foo", functionMap[1].Bindings[0].Name); - Assert.Equal(0, functionMap[1].Bindings[0].SourcePosition.Line); - Assert.Equal(9, functionMap[1].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[1].Start.Line); - Assert.Equal(0, functionMap[1].End.Line); - Assert.Equal(14, functionMap[1].Start.Column); - Assert.Equal(22, functionMap[1].End.Column); + Assert.AreEqual(2, functionMap.Count); + + Assert.AreEqual("bar", functionMap[0].Bindings[0].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(31, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(36, functionMap[0].Start.Column); + Assert.AreEqual(44, functionMap[0].End.Column); + + Assert.AreEqual("foo", functionMap[1].Bindings[0].Name); + Assert.AreEqual(0, functionMap[1].Bindings[0].SourcePosition.Line); + Assert.AreEqual(9, functionMap[1].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[1].Start.Line); + Assert.AreEqual(0, functionMap[1].End.Line); + Assert.AreEqual(14, functionMap[1].Start.Column); + Assert.AreEqual(22, functionMap[1].End.Column); } - [Fact] + [Test] public void ParseSourceCode_TwoNestedSingleLineFunctions_TwoFunctionMapEntries() { // Arrange @@ -117,26 +117,26 @@ public void ParseSourceCode_TwoNestedSingleLineFunctions_TwoFunctionMapEntries() var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Equal(2, functionMap.Count); - - Assert.Equal("bar", functionMap[0].Bindings[0].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(24, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(29, functionMap[0].Start.Column); - Assert.Equal(37, functionMap[0].End.Column); - - Assert.Equal("foo", functionMap[1].Bindings[0].Name); - Assert.Equal(0, functionMap[1].Bindings[0].SourcePosition.Line); - Assert.Equal(9, functionMap[1].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[1].Start.Line); - Assert.Equal(0, functionMap[1].End.Line); - Assert.Equal(14, functionMap[1].Start.Column); - Assert.Equal(38, functionMap[1].End.Column); + Assert.AreEqual(2, functionMap.Count); + + Assert.AreEqual("bar", functionMap[0].Bindings[0].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(24, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(29, functionMap[0].Start.Column); + Assert.AreEqual(37, functionMap[0].End.Column); + + Assert.AreEqual("foo", functionMap[1].Bindings[0].Name); + Assert.AreEqual(0, functionMap[1].Bindings[0].SourcePosition.Line); + Assert.AreEqual(9, functionMap[1].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[1].Start.Line); + Assert.AreEqual(0, functionMap[1].End.Line); + Assert.AreEqual(14, functionMap[1].Start.Column); + Assert.AreEqual(38, functionMap[1].End.Column); } - [Fact] + [Test] public void ParseSourceCode_FunctionAssignedToVariable_FunctionMapEntryGenerated() { // Arrange @@ -146,18 +146,18 @@ public void ParseSourceCode_FunctionAssignedToVariable_FunctionMapEntryGenerated var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Single(functionMap); - - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(4, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(20, functionMap[0].Start.Column); - Assert.Equal(28, functionMap[0].End.Column); + Assert.AreEqual(1, functionMap.Count); + + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(4, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(20, functionMap[0].Start.Column); + Assert.AreEqual(28, functionMap[0].End.Column); } - [Fact] + [Test] public void ParseSourceCode_StaticMethod_FunctionMapEntryGenerated() { // Arrange @@ -167,27 +167,27 @@ public void ParseSourceCode_StaticMethod_FunctionMapEntryGenerated() var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Equal(2, functionMap.Count); - - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal("bar", functionMap[0].Bindings[1].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(23, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(44, functionMap[0].Start.Column); - Assert.Equal(54, functionMap[0].End.Column); - - Assert.Equal("foo", functionMap[1].Bindings[0].Name); - Assert.Equal(0, functionMap[1].Bindings[0].SourcePosition.Line); - Assert.Equal(4, functionMap[1].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[1].Start.Line); - Assert.Equal(0, functionMap[1].End.Line); - Assert.Equal(20, functionMap[1].Start.Column); - Assert.Equal(22, functionMap[1].End.Column); + Assert.AreEqual(2, functionMap.Count); + + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual("bar", functionMap[0].Bindings[1].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(23, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(44, functionMap[0].Start.Column); + Assert.AreEqual(54, functionMap[0].End.Column); + + Assert.AreEqual("foo", functionMap[1].Bindings[0].Name); + Assert.AreEqual(0, functionMap[1].Bindings[0].SourcePosition.Line); + Assert.AreEqual(4, functionMap[1].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[1].Start.Line); + Assert.AreEqual(0, functionMap[1].End.Line); + Assert.AreEqual(20, functionMap[1].Start.Column); + Assert.AreEqual(22, functionMap[1].End.Column); } - [Fact] + [Test] public void ParseSourceCode_InstanceMethod_FunctionMapEntryGenerated() { // Arrange @@ -197,28 +197,28 @@ public void ParseSourceCode_InstanceMethod_FunctionMapEntryGenerated() var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Equal(2, functionMap.Count); - - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal("prototype", functionMap[0].Bindings[1].Name); - Assert.Equal("bar", functionMap[0].Bindings[2].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(24, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(56, functionMap[0].Start.Column); - Assert.Equal(66, functionMap[0].End.Column); - - Assert.Equal("foo", functionMap[1].Bindings[0].Name); - Assert.Equal(0, functionMap[1].Bindings[0].SourcePosition.Line); - Assert.Equal(4, functionMap[1].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[1].Start.Line); - Assert.Equal(0, functionMap[1].End.Line); - Assert.Equal(20, functionMap[1].Start.Column); - Assert.Equal(22, functionMap[1].End.Column); + Assert.AreEqual(2, functionMap.Count); + + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual("prototype", functionMap[0].Bindings[1].Name); + Assert.AreEqual("bar", functionMap[0].Bindings[2].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(24, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(56, functionMap[0].Start.Column); + Assert.AreEqual(66, functionMap[0].End.Column); + + Assert.AreEqual("foo", functionMap[1].Bindings[0].Name); + Assert.AreEqual(0, functionMap[1].Bindings[0].SourcePosition.Line); + Assert.AreEqual(4, functionMap[1].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[1].Start.Line); + Assert.AreEqual(0, functionMap[1].End.Line); + Assert.AreEqual(20, functionMap[1].Start.Column); + Assert.AreEqual(22, functionMap[1].End.Column); } - [Fact] + [Test] public void ParseSourceCode_InstanceMethodInObjectInitializer_FunctionMapEntryGenerated() { // Arrange @@ -228,30 +228,30 @@ public void ParseSourceCode_InstanceMethodInObjectInitializer_FunctionMapEntryGe var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Equal(2, functionMap.Count); - - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(24, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal("prototype", functionMap[0].Bindings[1].Name); - Assert.Equal("bar", functionMap[0].Bindings[2].Name); - Assert.Equal(0, functionMap[0].Bindings[2].SourcePosition.Line); - Assert.Equal(42, functionMap[0].Bindings[2].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(59, functionMap[0].Start.Column); - Assert.Equal(69, functionMap[0].End.Column); - - Assert.Equal("foo", functionMap[1].Bindings[0].Name); - Assert.Equal(0, functionMap[1].Bindings[0].SourcePosition.Line); - Assert.Equal(4, functionMap[1].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[1].Start.Line); - Assert.Equal(0, functionMap[1].End.Line); - Assert.Equal(20, functionMap[1].Start.Column); - Assert.Equal(22, functionMap[1].End.Column); + Assert.AreEqual(2, functionMap.Count); + + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(24, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual("prototype", functionMap[0].Bindings[1].Name); + Assert.AreEqual("bar", functionMap[0].Bindings[2].Name); + Assert.AreEqual(0, functionMap[0].Bindings[2].SourcePosition.Line); + Assert.AreEqual(42, functionMap[0].Bindings[2].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(59, functionMap[0].Start.Column); + Assert.AreEqual(69, functionMap[0].End.Column); + + Assert.AreEqual("foo", functionMap[1].Bindings[0].Name); + Assert.AreEqual(0, functionMap[1].Bindings[0].SourcePosition.Line); + Assert.AreEqual(4, functionMap[1].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[1].Start.Line); + Assert.AreEqual(0, functionMap[1].End.Line); + Assert.AreEqual(20, functionMap[1].Start.Column); + Assert.AreEqual(22, functionMap[1].End.Column); } - [Fact] + [Test] public void ParseSourceCode_FunctionAssignedToVariableAndHasName_FunctionMapEntryGeneratedForVariableName() { // Arrange @@ -261,18 +261,18 @@ public void ParseSourceCode_FunctionAssignedToVariableAndHasName_FunctionMapEntr var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Single(functionMap); - - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(4, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(39, functionMap[0].Start.Column); - Assert.Equal(49, functionMap[0].End.Column); + Assert.AreEqual(1, functionMap.Count); + + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(4, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(39, functionMap[0].Start.Column); + Assert.AreEqual(49, functionMap[0].End.Column); } - [Fact] + [Test] public void ParseSourceCode_StaticMethodAndFunctionHasName_FunctionMapEntryGeneratedForPropertyName() { // Arrange @@ -282,27 +282,27 @@ public void ParseSourceCode_StaticMethodAndFunctionHasName_FunctionMapEntryGener var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Equal(2, functionMap.Count); - - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal("bar", functionMap[0].Bindings[1].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(23, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(63, functionMap[0].Start.Column); - Assert.Equal(73, functionMap[0].End.Column); - - Assert.Equal("foo", functionMap[1].Bindings[0].Name); - Assert.Equal(0, functionMap[1].Bindings[0].SourcePosition.Line); - Assert.Equal(4, functionMap[1].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[1].Start.Line); - Assert.Equal(0, functionMap[1].End.Line); - Assert.Equal(20, functionMap[1].Start.Column); - Assert.Equal(22, functionMap[1].End.Column); + Assert.AreEqual(2, functionMap.Count); + + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual("bar", functionMap[0].Bindings[1].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(23, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(63, functionMap[0].Start.Column); + Assert.AreEqual(73, functionMap[0].End.Column); + + Assert.AreEqual("foo", functionMap[1].Bindings[0].Name); + Assert.AreEqual(0, functionMap[1].Bindings[0].SourcePosition.Line); + Assert.AreEqual(4, functionMap[1].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[1].Start.Line); + Assert.AreEqual(0, functionMap[1].End.Line); + Assert.AreEqual(20, functionMap[1].Start.Column); + Assert.AreEqual(22, functionMap[1].End.Column); } - [Fact] + [Test] public void ParseSourceCode_InstanceMethodAndFunctionHasName_FunctionMapEntryGeneratedForObjectPrototype() { // Arrange @@ -312,28 +312,28 @@ public void ParseSourceCode_InstanceMethodAndFunctionHasName_FunctionMapEntryGen var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Equal(2, functionMap.Count); - - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal("prototype", functionMap[0].Bindings[1].Name); - Assert.Equal("bar", functionMap[0].Bindings[2].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(24, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(74, functionMap[0].Start.Column); - Assert.Equal(84, functionMap[0].End.Column); - - Assert.Equal("foo", functionMap[1].Bindings[0].Name); - Assert.Equal(0, functionMap[1].Bindings[0].SourcePosition.Line); - Assert.Equal(4, functionMap[1].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[1].Start.Line); - Assert.Equal(0, functionMap[1].End.Line); - Assert.Equal(20, functionMap[1].Start.Column); - Assert.Equal(22, functionMap[1].End.Column); + Assert.AreEqual(2, functionMap.Count); + + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual("prototype", functionMap[0].Bindings[1].Name); + Assert.AreEqual("bar", functionMap[0].Bindings[2].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(24, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(74, functionMap[0].Start.Column); + Assert.AreEqual(84, functionMap[0].End.Column); + + Assert.AreEqual("foo", functionMap[1].Bindings[0].Name); + Assert.AreEqual(0, functionMap[1].Bindings[0].SourcePosition.Line); + Assert.AreEqual(4, functionMap[1].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[1].Start.Line); + Assert.AreEqual(0, functionMap[1].End.Line); + Assert.AreEqual(20, functionMap[1].Start.Column); + Assert.AreEqual(22, functionMap[1].End.Column); } - [Fact] + [Test] public void ParseSourceCode_InstanceMethodWithObjectInitializerAndFunctionHasName_FunctionMapEntryGeneratedForObjectPrototype() { // Arrange @@ -343,27 +343,27 @@ public void ParseSourceCode_InstanceMethodWithObjectInitializerAndFunctionHasNam var functionMap = FunctionMapGenerator.ParseSourceCode(UnitTestUtils.StreamFromString(sourceCode), CreateSourceMapMock()); // Assert - Assert.Equal(2, functionMap.Count); - - Assert.Equal("foo", functionMap[0].Bindings[0].Name); - Assert.Equal(0, functionMap[0].Bindings[0].SourcePosition.Line); - Assert.Equal(24, functionMap[0].Bindings[0].SourcePosition.Column); - Assert.Equal("prototype", functionMap[0].Bindings[1].Name); - Assert.Equal("bar", functionMap[0].Bindings[2].Name); - Assert.Equal(0, functionMap[0].Bindings[2].SourcePosition.Line); - Assert.Equal(42, functionMap[0].Bindings[2].SourcePosition.Column); - Assert.Equal(0, functionMap[0].Start.Line); - Assert.Equal(0, functionMap[0].End.Line); - Assert.Equal(77, functionMap[0].Start.Column); - Assert.Equal(87, functionMap[0].End.Column); - - Assert.Equal("foo", functionMap[1].Bindings[0].Name); - Assert.Equal(0, functionMap[1].Bindings[0].SourcePosition.Line); - Assert.Equal(4, functionMap[1].Bindings[0].SourcePosition.Column); - Assert.Equal(0, functionMap[1].Start.Line); - Assert.Equal(0, functionMap[1].End.Line); - Assert.Equal(20, functionMap[1].Start.Column); - Assert.Equal(22, functionMap[1].End.Column); + Assert.AreEqual(2, functionMap.Count); + + Assert.AreEqual("foo", functionMap[0].Bindings[0].Name); + Assert.AreEqual(0, functionMap[0].Bindings[0].SourcePosition.Line); + Assert.AreEqual(24, functionMap[0].Bindings[0].SourcePosition.Column); + Assert.AreEqual("prototype", functionMap[0].Bindings[1].Name); + Assert.AreEqual("bar", functionMap[0].Bindings[2].Name); + Assert.AreEqual(0, functionMap[0].Bindings[2].SourcePosition.Line); + Assert.AreEqual(42, functionMap[0].Bindings[2].SourcePosition.Column); + Assert.AreEqual(0, functionMap[0].Start.Line); + Assert.AreEqual(0, functionMap[0].End.Line); + Assert.AreEqual(77, functionMap[0].Start.Column); + Assert.AreEqual(87, functionMap[0].End.Column); + + Assert.AreEqual("foo", functionMap[1].Bindings[0].Name); + Assert.AreEqual(0, functionMap[1].Bindings[0].SourcePosition.Line); + Assert.AreEqual(4, functionMap[1].Bindings[0].SourcePosition.Column); + Assert.AreEqual(0, functionMap[1].Start.Line); + Assert.AreEqual(0, functionMap[1].End.Line); + Assert.AreEqual(20, functionMap[1].Start.Column); + Assert.AreEqual(22, functionMap[1].End.Column); } private static SourceMap CreateSourceMapMock() diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/KeyValueCacheUnitTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/KeyValueCacheUnitTests.cs index a3d2869..f3f4009 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/KeyValueCacheUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/KeyValueCacheUnitTests.cs @@ -1,13 +1,13 @@ using System; using Moq; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { public class KeyValueCacheUnitTests { - [Fact] + [Test] public void GetValue_KeyNotInCache_CallValueGetter() { // Arrange @@ -19,11 +19,11 @@ public void GetValue_KeyNotInCache_CallValueGetter() var result = keyValueCache.GetValue("bar"); // Assert - Assert.Equal("foo", result); + Assert.AreEqual("foo", result); } - [Fact] + [Test] public void GetValue_CallGetTwice_OnlyCallValueGetterOnce() { // Arrange @@ -36,11 +36,11 @@ public void GetValue_CallGetTwice_OnlyCallValueGetterOnce() var result = keyValueCache.GetValue("bar"); // Assert - Assert.Equal("foo", result); + Assert.AreEqual("foo", result); valueGetter.Verify(x => x("bar"), Times.Once()); } - [Fact] + [Test] public void GetValue_CallGetTwiceValueGetterReturnsNull_CallGetterTwice() { // Arrange @@ -57,7 +57,7 @@ public void GetValue_CallGetTwiceValueGetterReturnsNull_CallGetterTwice() valueGetter.Verify(x => x("bar"), Times.Exactly(2)); } - [Fact] + [Test] public void GetValue_CallGetMultipleTimesFirstGetterReturnsNull_CacheFirstNonNullValue() { // Arrange @@ -74,7 +74,7 @@ public void GetValue_CallGetMultipleTimesFirstGetterReturnsNull_CacheFirstNonNul var result = keyValueCache.GetValue("bar"); // Assert - Assert.Equal("foo", result); + Assert.AreEqual("foo", result); valueGetter.Verify(x => x("bar"), Times.Exactly(2)); } } diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/SourceMapExtensionsUnitTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/SourceMapExtensionsUnitTests.cs index 2175585..980a025 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/SourceMapExtensionsUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/SourceMapExtensionsUnitTests.cs @@ -1,13 +1,13 @@ using System.Collections.Generic; using Moq; using SourcemapToolkit.SourcemapParser; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { public class SourceMapExtensionsUnitTests { - [Fact] + [Test] public void GetDeminifiedMethodName_EmptyBinding_ReturnNullMethodName() { // Arrange @@ -21,7 +21,7 @@ public void GetDeminifiedMethodName_EmptyBinding_ReturnNullMethodName() Assert.Null(result); } - [Fact] + [Test] public void GetDeminifiedMethodName_HasSingleBindingNoMatchingMapping_ReturnNullMethodName() { // Arrange @@ -42,7 +42,7 @@ public void GetDeminifiedMethodName_HasSingleBindingNoMatchingMapping_ReturnNull Assert.Null(result); } - [Fact] + [Test] public void GetDeminifiedMethodName_HasSingleBindingMatchingMapping_ReturnsMethodName() { // Arrange @@ -64,11 +64,11 @@ public void GetDeminifiedMethodName_HasSingleBindingMatchingMapping_ReturnsMetho var result = SourceMapExtensions.GetDeminifiedMethodName(sourceMap.Object, bindings); // Assert - Assert.Equal("foo", result); + Assert.AreEqual("foo", result); sourceMap.Verify(); } - [Fact] + [Test] public void GetDeminifiedMethodName_MatchingMappingMultipleBindingsMissingPrototypeMapping_ReturnsMethodName() { // Arrange @@ -99,11 +99,11 @@ public void GetDeminifiedMethodName_MatchingMappingMultipleBindingsMissingProtot var result = SourceMapExtensions.GetDeminifiedMethodName(sourceMap.Object, bindings); // Assert - Assert.Equal("baz", result); + Assert.AreEqual("baz", result); sourceMap.Verify(); } - [Fact] + [Test] public void GetDeminifiedMethodName_MatchingMappingMultipleBindings_ReturnsMethodNameWithFullBinding() { // Arrange @@ -134,7 +134,7 @@ public void GetDeminifiedMethodName_MatchingMappingMultipleBindings_ReturnsMetho var result = SourceMapExtensions.GetDeminifiedMethodName(sourceMap.Object, bindings); // Assert - Assert.Equal("bar.baz", result); + Assert.AreEqual("bar.baz", result); sourceMap.Verify(); } diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackFrameDeminifierUnitTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackFrameDeminifierUnitTests.cs index 3b2dd82..0b3270d 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackFrameDeminifierUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackFrameDeminifierUnitTests.cs @@ -2,9 +2,8 @@ using System.Collections.Generic; using Moq; using SourcemapToolkit.SourcemapParser; -using Xunit; +using NUnit.Framework; -[assembly: CollectionBehavior(DisableTestParallelization = true)] namespace SourcemapToolkit.CallstackDeminifier.UnitTests { @@ -37,18 +36,7 @@ private static IStackFrameDeminifier GetStackFrameDeminifierWithMockDependencies } } - [Fact] - public void DeminifyStackFrame_NullInputStackFrame_ThrowsException() - { - // Arrange - var stackFrameDeminifier = GetStackFrameDeminifierWithMockDependencies(); - StackFrame? stackFrame = null; - - // Act - Assert.Throws(() => stackFrameDeminifier.DeminifyStackFrame(stackFrame!, callerSymbolName: null)); - } - - [Fact] + [Test] public void DeminifyStackFrame_StackFrameNullProperties_DoesNotThrowException() { // Arrange @@ -60,11 +48,11 @@ public void DeminifyStackFrame_StackFrameNullProperties_DoesNotThrowException() // Assert Assert.Null(stackFrameDeminification.DeminifiedStackFrame.MethodName); - Assert.Equal(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); + Assert.AreEqual(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath); } - [Fact] + [Test] public void SimpleStackFrameDeminierDeminifyStackFrame_FunctionMapReturnsNull_NoFunctionMapDeminificationError() { // Arrange @@ -80,13 +68,13 @@ public void SimpleStackFrameDeminierDeminifyStackFrame_FunctionMapReturnsNull_No var stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null); // Assert - Assert.Equal(DeminificationError.NoSourceCodeProvided, stackFrameDeminification.DeminificationError); + Assert.AreEqual(DeminificationError.NoSourceCodeProvided, stackFrameDeminification.DeminificationError); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.MethodName); - Assert.Equal(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); + Assert.AreEqual(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath); } - [Fact] + [Test] public void SimpleStackFrameDeminierDeminifyStackFrame_GetWRappingFunctionForSourceLocationReturnsNull_NoWrapingFunctionDeminificationError() { // Arrange @@ -105,13 +93,13 @@ public void SimpleStackFrameDeminierDeminifyStackFrame_GetWRappingFunctionForSou var stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null); // Assert - Assert.Equal(DeminificationError.NoWrapingFunctionFound, stackFrameDeminification.DeminificationError); + Assert.AreEqual(DeminificationError.NoWrapingFunctionFound, stackFrameDeminification.DeminificationError); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.MethodName); - Assert.Equal(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); + Assert.AreEqual(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath); } - [Fact] + [Test] public void SimpleStackFrameDeminierDeminifyStackFrame_WrapingFunctionFound_NoDeminificationError() { // Arrange @@ -131,14 +119,14 @@ public void SimpleStackFrameDeminierDeminifyStackFrame_WrapingFunctionFound_NoDe var stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null); // Assert - Assert.Equal(DeminificationError.None, stackFrameDeminification.DeminificationError); - Assert.Equal(wrapingFunctionMapEntry.DeminifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName); - Assert.Equal(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); + Assert.AreEqual(DeminificationError.None, stackFrameDeminification.DeminificationError); + Assert.AreEqual(wrapingFunctionMapEntry.DeminifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName); + Assert.AreEqual(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath); } - [Fact] + [Test] public void StackFrameDeminierDeminifyStackFrame_SourceMapProviderReturnsNull_NoSourcemapProvidedError() { // Arrange @@ -158,13 +146,13 @@ public void StackFrameDeminierDeminifyStackFrame_SourceMapProviderReturnsNull_No var stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null); // Assert - Assert.Equal(DeminificationError.NoSourceMap, stackFrameDeminification.DeminificationError); - Assert.Equal(wrapingFunctionMapEntry.DeminifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName); - Assert.Equal(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); + Assert.AreEqual(DeminificationError.NoSourceMap, stackFrameDeminification.DeminificationError); + Assert.AreEqual(wrapingFunctionMapEntry.DeminifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName); + Assert.AreEqual(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath); } - [Fact] + [Test] public void StackFrameDeminierDeminifyStackFrame_SourceMapParsingNull_SourceMapFailedToParseError() { // Arrange @@ -186,13 +174,13 @@ public void StackFrameDeminierDeminifyStackFrame_SourceMapParsingNull_SourceMapF var stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null); // Assert - Assert.Equal(DeminificationError.NoMatchingMapingInSourceMap, stackFrameDeminification.DeminificationError); - Assert.Equal(wrapingFunctionMapEntry.DeminifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName); - Assert.Equal(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); + Assert.AreEqual(DeminificationError.NoMatchingMapingInSourceMap, stackFrameDeminification.DeminificationError); + Assert.AreEqual(wrapingFunctionMapEntry.DeminifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName); + Assert.AreEqual(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath); } - [Fact] + [Test] public void StackFrameDeminierDeminifyStackFrame_SourceMapGeneratedMappingEntryNull_NoMatchingMapingInSourceMapError() { // Arrange @@ -216,9 +204,9 @@ public void StackFrameDeminierDeminifyStackFrame_SourceMapGeneratedMappingEntryN var stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null); // Assert - Assert.Equal(DeminificationError.NoMatchingMapingInSourceMap, stackFrameDeminification.DeminificationError); - Assert.Equal(wrapingFunctionMapEntry.DeminifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName); - Assert.Equal(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); + Assert.AreEqual(DeminificationError.NoMatchingMapingInSourceMap, stackFrameDeminification.DeminificationError); + Assert.AreEqual(wrapingFunctionMapEntry.DeminifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName); + Assert.AreEqual(SourcePosition.NotFound, stackFrameDeminification.DeminifiedStackFrame.SourcePosition); Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath); } diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierClosureEndToEndTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierClosureEndToEndTests.cs index 184b201..76a93f7 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierClosureEndToEndTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierClosureEndToEndTests.cs @@ -1,6 +1,6 @@ using Moq; using SourcemapToolkit.SourcemapParser.UnitTests; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { @@ -23,15 +23,15 @@ private static StackTraceDeminifier GetStackTraceDeminifierWithDependencies() private static void ValidateDeminifyStackTraceResults(DeminifyStackTraceResult results) { - Assert.Equal(4, results.DeminifiedStackFrameResults.Count); - Assert.Equal(DeminificationError.None, results.DeminifiedStackFrameResults[0].DeminificationError); - Assert.Equal("mynamespace.objectWithMethods.propertyMethodLevel2", results.DeminifiedStackFrameResults[0].DeminifiedStackFrame.MethodName); - Assert.Equal("mynamespace.objectWithMethods.prototypeMethodLevel1", results.DeminifiedStackFrameResults[1].DeminifiedStackFrame.MethodName); - Assert.Equal("GlobalFunction", results.DeminifiedStackFrameResults[2].DeminifiedStackFrame.MethodName); - Assert.Equal("window.onload", results.DeminifiedStackFrameResults[3].DeminifiedStackFrame.MethodName); + Assert.AreEqual(4, results.DeminifiedStackFrameResults.Count); + Assert.AreEqual(DeminificationError.None, results.DeminifiedStackFrameResults[0].DeminificationError); + Assert.AreEqual("mynamespace.objectWithMethods.propertyMethodLevel2", results.DeminifiedStackFrameResults[0].DeminifiedStackFrame.MethodName); + Assert.AreEqual("mynamespace.objectWithMethods.prototypeMethodLevel1", results.DeminifiedStackFrameResults[1].DeminifiedStackFrame.MethodName); + Assert.AreEqual("GlobalFunction", results.DeminifiedStackFrameResults[2].DeminifiedStackFrame.MethodName); + Assert.AreEqual("window.onload", results.DeminifiedStackFrameResults[3].DeminifiedStackFrame.MethodName); } - [Fact] + [Test] public void DeminifyClosureStackTrace_ChromeStackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -49,7 +49,7 @@ at c (http://localhost:11323/closurecrashcauser.minified.js:1:135) ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyClosureStackTrace_FireFoxStackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -66,7 +66,7 @@ public void DeminifyClosureStackTrace_FireFoxStackTraceString_CorrectDeminificat ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyClosureStackTrace_IE11StackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -84,7 +84,7 @@ at c (http://localhost:11323/closurecrashcauser.minified.js:1:121) ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyClosureStackTrace_EdgeStackTraceString_CorrectDeminificationWhenPossible() { // Arrange diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierEndToEndTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierEndToEndTests.cs index b869f21..aea2ee3 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierEndToEndTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierEndToEndTests.cs @@ -1,10 +1,9 @@ using Moq; using SourcemapToolkit.SourcemapParser.UnitTests; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { - public class StackTraceDeminifierEndToEndTests { private const string GeneratedCodeString = "function causeCrash(){function n(){var n=16;n+=2;t(n)}function t(n){n=n+2;i(n)}function i(n){(function(){var t;console.log(t.length+n)})()}window.onerror=function(n,t,i,r,u){u?document.getElementById(\"callstackdisplay\").innerText=u.stack:window.event.error&&(document.getElementById(\"callstackdisplay\").innerText=window.event.error.stack)};n()}window.onload=function(){document.getElementById(\"crashbutton\").addEventListener(\"click\",function(){causeCrash()})};"; @@ -24,17 +23,17 @@ private static StackTraceDeminifier GetStackTraceDeminifierWithDependencies() private static void ValidateDeminifyStackTraceResults(DeminifyStackTraceResult results) { - Assert.Equal(6, results.DeminifiedStackFrameResults.Count); - Assert.Equal(DeminificationError.None, results.DeminifiedStackFrameResults[0].DeminificationError); - Assert.Equal("level3", results.DeminifiedStackFrameResults[0].DeminifiedStackFrame.MethodName); - Assert.Equal("level3", results.DeminifiedStackFrameResults[1].DeminifiedStackFrame.MethodName); - Assert.Equal("level2", results.DeminifiedStackFrameResults[2].DeminifiedStackFrame.MethodName); - Assert.Equal("level1", results.DeminifiedStackFrameResults[3].DeminifiedStackFrame.MethodName); - Assert.Equal("causeCrash", results.DeminifiedStackFrameResults[4].DeminifiedStackFrame.MethodName); - Assert.Equal("window.onload", results.DeminifiedStackFrameResults[5].DeminifiedStackFrame.MethodName); + Assert.AreEqual(6, results.DeminifiedStackFrameResults.Count); + Assert.AreEqual(DeminificationError.None, results.DeminifiedStackFrameResults[0].DeminificationError); + Assert.AreEqual("level3", results.DeminifiedStackFrameResults[0].DeminifiedStackFrame.MethodName); + Assert.AreEqual("level3", results.DeminifiedStackFrameResults[1].DeminifiedStackFrame.MethodName); + Assert.AreEqual("level2", results.DeminifiedStackFrameResults[2].DeminifiedStackFrame.MethodName); + Assert.AreEqual("level1", results.DeminifiedStackFrameResults[3].DeminifiedStackFrame.MethodName); + Assert.AreEqual("causeCrash", results.DeminifiedStackFrameResults[4].DeminifiedStackFrame.MethodName); + Assert.AreEqual("window.onload", results.DeminifiedStackFrameResults[5].DeminifiedStackFrame.MethodName); } - [Fact] + [Test] public void DeminifyStackTrace_ChromeStackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -54,7 +53,7 @@ at causeCrash (http://localhost:11323/crashcauser.min.js:1:341) ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyStackTrace_FireFoxStackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -73,7 +72,7 @@ public void DeminifyStackTrace_FireFoxStackTraceString_CorrectDeminificationWhen ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyStackTrace_IE11StackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -93,7 +92,7 @@ at causeCrash (http://localhost:11323/crashcauser.min.js:1:341) ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyStackTrace_EdgeStackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -113,7 +112,7 @@ at causeCrash (http://localhost:11323/crashcauser.min.js:1:341) ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyResultToString_SuccessfullyDeminified_AllLinesDeminified() { // Arrange @@ -138,7 +137,7 @@ at causeCrash (http://localhost:11323/crashcauser.min.js:1:341) var formatted = results.ToString(); // Assert - Assert.Equal(exectedResult.Replace("\r", ""), formatted.Replace("\r", "")); + Assert.AreEqual(exectedResult.Replace("\r", ""), formatted.Replace("\r", "")); } } } \ No newline at end of file diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierMapOnlyEndToEndTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierMapOnlyEndToEndTests.cs index 070c8f8..c5de90f 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierMapOnlyEndToEndTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierMapOnlyEndToEndTests.cs @@ -1,6 +1,6 @@ using Moq; using SourcemapToolkit.SourcemapParser.UnitTests; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { @@ -24,17 +24,17 @@ private static StackTraceDeminifier GetStackTraceDeminifierWithDependencies() private static void ValidateDeminifyStackTraceResults(DeminifyStackTraceResult results) { - Assert.Equal(6, results.DeminifiedStackFrameResults.Count); - Assert.Equal(DeminificationError.None, results.DeminifiedStackFrameResults[0].DeminificationError); - Assert.Equal(16, results.DeminifiedStackFrameResults[0].DeminifiedStackFrame.SourcePosition!.Line); - Assert.Equal("level3", results.DeminifiedStackFrameResults[1].DeminifiedStackFrame.MethodName); - Assert.Equal("level2", results.DeminifiedStackFrameResults[2].DeminifiedStackFrame.MethodName); - Assert.Equal("level1", results.DeminifiedStackFrameResults[3].DeminifiedStackFrame.MethodName); - Assert.Equal("causeCrash", results.DeminifiedStackFrameResults[4].DeminifiedStackFrame.MethodName); - Assert.Equal(32, results.DeminifiedStackFrameResults[5].DeminifiedStackFrame.SourcePosition!.Line); + Assert.AreEqual(6, results.DeminifiedStackFrameResults.Count); + Assert.AreEqual(DeminificationError.None, results.DeminifiedStackFrameResults[0].DeminificationError); + Assert.AreEqual(16, results.DeminifiedStackFrameResults[0].DeminifiedStackFrame.SourcePosition!.Line); + Assert.AreEqual("level3", results.DeminifiedStackFrameResults[1].DeminifiedStackFrame.MethodName); + Assert.AreEqual("level2", results.DeminifiedStackFrameResults[2].DeminifiedStackFrame.MethodName); + Assert.AreEqual("level1", results.DeminifiedStackFrameResults[3].DeminifiedStackFrame.MethodName); + Assert.AreEqual("causeCrash", results.DeminifiedStackFrameResults[4].DeminifiedStackFrame.MethodName); + Assert.AreEqual(32, results.DeminifiedStackFrameResults[5].DeminifiedStackFrame.SourcePosition!.Line); } - [Fact] + [Test] public void DeminifyStackTrace_ChromeStackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -54,7 +54,7 @@ at causeCrash (http://localhost:11323/crashcauser.min.js:1:341) ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyStackTrace_FireFoxStackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -73,7 +73,7 @@ public void DeminifyStackTrace_FireFoxStackTraceString_CorrectDeminificationWhen ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyStackTrace_IE11StackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -93,7 +93,7 @@ at causeCrash (http://localhost:11323/crashcauser.min.js:1:341) ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyStackTrace_EdgeStackTraceString_CorrectDeminificationWhenPossible() { // Arrange @@ -113,7 +113,7 @@ at causeCrash (http://localhost:11323/crashcauser.min.js:1:341) ValidateDeminifyStackTraceResults(results); } - [Fact] + [Test] public void DeminifyResultToString_SuccessfullyDeminified_AllLinesDeminified() { // Arrange @@ -138,7 +138,7 @@ at causeCrash (http://localhost:11323/crashcauser.min.js:1:341) var formatted = results.ToString(); // Assert - Assert.Equal(exectedResult.Replace("\r", ""), formatted.Replace("\r", "")); + Assert.AreEqual(exectedResult.Replace("\r", ""), formatted.Replace("\r", "")); } } } \ No newline at end of file diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierUnitTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierUnitTests.cs index 4e7d853..9c2e5b4 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierUnitTests.cs @@ -1,13 +1,13 @@ using System.Collections.Generic; using Moq; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { public class StackTraceDeminifierUnitTests { - [Fact] + [Test] public void DeminifyStackTrace_UnableToParseStackTraceString_ReturnsEmptyList() { // Arrange @@ -24,10 +24,10 @@ public void DeminifyStackTrace_UnableToParseStackTraceString_ReturnsEmptyList() var result = stackTraceDeminifier.DeminifyStackTrace(stackTraceString); // Assert - Assert.Equal(0, result.DeminifiedStackFrameResults.Count); + Assert.AreEqual(0, result.DeminifiedStackFrameResults.Count); } - [Fact] + [Test] public void DeminifyStackTrace_AbleToDeminifyStackTrace_ResultContainsDeminifiedFrame() { // Arrange @@ -47,9 +47,9 @@ public void DeminifyStackTrace_AbleToDeminifyStackTrace_ResultContainsDeminified var result = stackTraceDeminifier.DeminifyStackTrace(stackTraceString); // Assert - Assert.Equal(1, result.DeminifiedStackFrameResults.Count); - Assert.Equal(minifiedStackFrames[0], result.MinifiedStackFrames[0]); - Assert.Equal(stackFrameDeminification, result.DeminifiedStackFrameResults[0]); + Assert.AreEqual(1, result.DeminifiedStackFrameResults.Count); + Assert.AreEqual(minifiedStackFrames[0], result.MinifiedStackFrames[0]); + Assert.AreEqual(stackFrameDeminification, result.DeminifiedStackFrameResults[0]); } } } \ No newline at end of file diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierWebpackEndToEndTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierWebpackEndToEndTests.cs index 160a733..198d938 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierWebpackEndToEndTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceDeminifierWebpackEndToEndTests.cs @@ -1,6 +1,6 @@ using System; using System.IO; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { @@ -33,7 +33,7 @@ private static StackTraceDeminifier GetStackTraceDeminifierWithDependencies() return StackTraceDeminifierFactory.GetStackTraceDeminfier(provider, provider); } - [Fact] + [Test] public void DeminifyStackTrace_MinifiedStackTrace_CorrectDeminificationWhenPossible() { // Arrange @@ -49,7 +49,7 @@ at t.onButtonClick (http://localhost:3000/js/bundle.ffe51781aee314a37903.min.js: var results = stackTraceDeminifier.DeminifyStackTrace(chromeStackTrace); // Assert - Assert.Equal(deminifiedStackTrace.Replace("\r", ""), results.ToString().Replace("\r", "")); + Assert.AreEqual(deminifiedStackTrace.Replace("\r", ""), results.ToString().Replace("\r", "")); } } } \ No newline at end of file diff --git a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceParserUnitTests.cs b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceParserUnitTests.cs index e0cfc49..c9d0614 100644 --- a/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceParserUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/CallstackDeminifier/StackTraceParserUnitTests.cs @@ -1,23 +1,12 @@ using System; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.CallstackDeminifier.UnitTests { public class StackTraceParserUnitTests { - [Fact] - public void ParseStackTrace_NullInput_ThrowsArgumentNullException() - { - // Arrange - IStackTraceParser stackTraceParser = new StackTraceParser(); - string? browserStackTrace = null; - - // Act - Assert.Throws(() => stackTraceParser.ParseStackTrace(browserStackTrace!)); - } - - [Fact] + [Test] public void ParseStackTrace_ChromeCallstack_GenerateCorrectNumberOfStackFrames() { // Arrange @@ -32,10 +21,10 @@ at b (http://localhost:19220/crashcauser.min.js:1:14) var stackTrace = stackTraceParser.ParseStackTrace(browserStackTrace); // Assert - Assert.Equal(4, stackTrace.Count); + Assert.AreEqual(4, stackTrace.Count); } - [Fact] + [Test] public void ParseStackTrace_FireFoxCallstack_GenerateCorrectNumberOfStackFrames() { // Arrange @@ -49,10 +38,10 @@ public void ParseStackTrace_FireFoxCallstack_GenerateCorrectNumberOfStackFrames( var stackTrace = stackTraceParser.ParseStackTrace(browserStackTrace); // Assert - Assert.Equal(4, stackTrace.Count); + Assert.AreEqual(4, stackTrace.Count); } - [Fact] + [Test] public void ParseStackTrace_InternetExplorer11Callstack_GenerateCorrectNumberOfStackFrames() { // Arrange @@ -66,21 +55,10 @@ at c (http://localhost:19220/crashcauser.min.js:1:34) var stackTrace = stackTraceParser.ParseStackTrace(browserStackTrace); // Assert - Assert.Equal(3, stackTrace.Count); - } - - [Fact] - public void TryParseSingleStackFrame_NullInput_ThrowsNullArgumentException() - { - // Arrange - var stackTraceParser = new StackTraceParser(); - string? frame = null; - - // Act - Assert.Throws(() => stackTraceParser.TryParseSingleStackFrame(frame!)); + Assert.AreEqual(3, stackTrace.Count); } - [Fact] + [Test] public void TryParseSingleStackFrame_EmptyString_ReturnNull() { // Arrange @@ -94,7 +72,7 @@ public void TryParseSingleStackFrame_EmptyString_ReturnNull() Assert.Null(result); } - [Fact] + [Test] public void TryParseSingleStackFrame_NoMethodNameInInput_ReturnsStackFrameWithNullMethod() { // Arrange @@ -105,13 +83,13 @@ public void TryParseSingleStackFrame_NoMethodNameInInput_ReturnsStackFrameWithNu var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("http://localhost:19220/crashcauser.min.js", result.FilePath); + Assert.AreEqual("http://localhost:19220/crashcauser.min.js", result.FilePath); Assert.Null(result.MethodName); - Assert.Equal(0, result.SourcePosition!.Line); - Assert.Equal(33, result.SourcePosition.Column); + Assert.AreEqual(0, result.SourcePosition!.Line); + Assert.AreEqual(33, result.SourcePosition.Column); } - [Fact] + [Test] public void TryParseSingleStackFrame_StackFrameWithWebpackLink_CorrectStackFrame() { // Arrange @@ -122,13 +100,13 @@ public void TryParseSingleStackFrame_StackFrameWithWebpackLink_CorrectStackFrame var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("webpack-internal:///./Static/jsx/InitialStep/InitialStepForm.js", result.FilePath); - Assert.Equal("eval", result.MethodName); - Assert.Equal(167 - 1, result.SourcePosition!.Line); - Assert.Equal(14 - 1, result.SourcePosition.Column); + Assert.AreEqual("webpack-internal:///./Static/jsx/InitialStep/InitialStepForm.js", result.FilePath); + Assert.AreEqual("eval", result.MethodName); + Assert.AreEqual(167 - 1, result.SourcePosition!.Line); + Assert.AreEqual(14 - 1, result.SourcePosition.Column); } - [Fact] + [Test] public void TryParseSingleStackFrame_StackFrameWithoutParentheses_CorrectStackFrame() { // Arrange @@ -139,13 +117,13 @@ public void TryParseSingleStackFrame_StackFrameWithoutParentheses_CorrectStackFr var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("http://localhost:19220/crashcauser.min.js", result.FilePath); - Assert.Equal("c", result.MethodName); - Assert.Equal(7, result.SourcePosition!.Line); - Assert.Equal(2, result.SourcePosition.Column); + Assert.AreEqual("http://localhost:19220/crashcauser.min.js", result.FilePath); + Assert.AreEqual("c", result.MethodName); + Assert.AreEqual(7, result.SourcePosition!.Line); + Assert.AreEqual(2, result.SourcePosition.Column); } - [Fact] + [Test] public void TryParseSingleStackFrame_ChromeStackFrame_CorrectStackFrame() { // Arrange @@ -156,13 +134,13 @@ public void TryParseSingleStackFrame_ChromeStackFrame_CorrectStackFrame() var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("http://localhost:19220/crashcauser.min.js", result.FilePath); - Assert.Equal("c", result.MethodName); - Assert.Equal(7, result.SourcePosition!.Line); - Assert.Equal(2, result.SourcePosition.Column); + Assert.AreEqual("http://localhost:19220/crashcauser.min.js", result.FilePath); + Assert.AreEqual("c", result.MethodName); + Assert.AreEqual(7, result.SourcePosition!.Line); + Assert.AreEqual(2, result.SourcePosition.Column); } - [Fact] + [Test] public void TryParseSingleStackFrame_ChromeStackFrameWithNoMethodName_CorrectStackFrame() { // Arrange @@ -173,13 +151,13 @@ public void TryParseSingleStackFrame_ChromeStackFrameWithNoMethodName_CorrectSta var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("http://localhost:19220/crashcauser.min.js", result.FilePath); + Assert.AreEqual("http://localhost:19220/crashcauser.min.js", result.FilePath); Assert.Null(result.MethodName); - Assert.Equal(9, result.SourcePosition!.Line); - Assert.Equal(12, result.SourcePosition.Column); + Assert.AreEqual(9, result.SourcePosition!.Line); + Assert.AreEqual(12, result.SourcePosition.Column); } - [Fact] + [Test] public void TryParseSingleStackFrame_ChromeStackFrameWithScriptSubfolder_CorrectStackFrame() { // Arrange @@ -190,13 +168,13 @@ public void TryParseSingleStackFrame_ChromeStackFrameWithScriptSubfolder_Correct var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("http://localhost:19220/o/app_scripts/crashcauser.min.js", result.FilePath); - Assert.Equal("c", result.MethodName); - Assert.Equal(8, result.SourcePosition!.Line); - Assert.Equal(4, result.SourcePosition.Column); + Assert.AreEqual("http://localhost:19220/o/app_scripts/crashcauser.min.js", result.FilePath); + Assert.AreEqual("c", result.MethodName); + Assert.AreEqual(8, result.SourcePosition!.Line); + Assert.AreEqual(4, result.SourcePosition.Column); } - [Fact] + [Test] public void TryParseSingleStackFrame_FireFoxStackFrame_CorrectStackFrame() { // Arrange @@ -207,13 +185,13 @@ public void TryParseSingleStackFrame_FireFoxStackFrame_CorrectStackFrame() var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("http://localhost:19220/crashcauser.min.js", result.FilePath); - Assert.Equal("c", result.MethodName); - Assert.Equal(3, result.SourcePosition!.Line); - Assert.Equal(51, result.SourcePosition.Column); + Assert.AreEqual("http://localhost:19220/crashcauser.min.js", result.FilePath); + Assert.AreEqual("c", result.MethodName); + Assert.AreEqual(3, result.SourcePosition!.Line); + Assert.AreEqual(51, result.SourcePosition.Column); } - [Fact] + [Test] public void TryParseSingleStackFrame_IE11StackFrame_CorrectStackFrame() { // Arrange @@ -224,13 +202,13 @@ public void TryParseSingleStackFrame_IE11StackFrame_CorrectStackFrame() var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("http://localhost:19220/crashcauser.min.js", result.FilePath); - Assert.Equal("c", result.MethodName); - Assert.Equal(2, result.SourcePosition!.Line); - Assert.Equal(16, result.SourcePosition.Column); + Assert.AreEqual("http://localhost:19220/crashcauser.min.js", result.FilePath); + Assert.AreEqual("c", result.MethodName); + Assert.AreEqual(2, result.SourcePosition!.Line); + Assert.AreEqual(16, result.SourcePosition.Column); } - [Fact] + [Test] public void TryParseSingleStackFrame_IE11StackFrameWithAnonymousFunction_CorrectStackFrame() { // Arrange @@ -241,10 +219,10 @@ public void TryParseSingleStackFrame_IE11StackFrameWithAnonymousFunction_Correct var result = stackTraceParser.TryParseSingleStackFrame(frame)!; // Assert - Assert.Equal("http://localhost:19220/crashcauser.min.js", result.FilePath); - Assert.Equal("Anonymous function", result.MethodName); - Assert.Equal(4, result.SourcePosition!.Line); - Assert.Equal(24, result.SourcePosition.Column); + Assert.AreEqual("http://localhost:19220/crashcauser.min.js", result.FilePath); + Assert.AreEqual("Anonymous function", result.MethodName); + Assert.AreEqual(4, result.SourcePosition!.Line); + Assert.AreEqual(24, result.SourcePosition.Column); } } } \ No newline at end of file diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/Base64ConverterUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/Base64ConverterUnitTests.cs index fb7682a..f1ae6b2 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/Base64ConverterUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/Base64ConverterUnitTests.cs @@ -1,56 +1,56 @@ using System; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class Base64ConverterUnitTests { - [Fact] + [Test] public void FromBase64_ValidBase64InputC_CorrectIntegerOutput2() { // Act var value = Base64Converter.FromBase64('C'); // Assert - Assert.Equal(2, value); + Assert.AreEqual(2, value); } - [Fact] + [Test] public void FromBase64_ValidBase64Input9_CorrectIntegerOutput61() { // Act var value = Base64Converter.FromBase64('9'); // Assert - Assert.Equal(61, value); + Assert.AreEqual(61, value); } - [Fact] + [Test] public void FromBase64_InvalidBase64Input_ThrowsException() { // Act Assert.Throws(() => Base64Converter.FromBase64('@')); } - [Fact] + [Test] public void ToBase64_ValidIntegerInput61_CorrectBase64Output9() { // Act var value = Base64Converter.ToBase64(61); // Assert - Assert.Equal('9', value); + Assert.AreEqual('9', value); } - [Fact] + [Test] public void ToBase64_NegativeIntegerInput_ThrowsException() { // Act Assert.Throws(() => Base64Converter.ToBase64(-1)); } - [Fact] + [Test] public void ToBase64_InvalidIntegerInput_ThrowsException() { // Act diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/Base64VlqDecoderUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/Base64VlqDecoderUnitTests.cs index 81ded15..68def7b 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/Base64VlqDecoderUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/Base64VlqDecoderUnitTests.cs @@ -1,12 +1,11 @@ using System.Collections.Generic; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { - public class Base64VlqDecoderUnitTests { - [Fact] + [Test] public void Base64VlqDecoder_SingleEncodedValue_ListWithOnlyOneValue() { // Arrange @@ -16,10 +15,10 @@ public void Base64VlqDecoder_SingleEncodedValue_ListWithOnlyOneValue() var result = Base64VlqDecoder.Decode(input); // Assert - Assert.Equal(new List { 701 }, result); + Assert.AreEqual(new List { 701 }, result); } - [Fact] + [Test] public void Base64VlqDecoder_MultipleEncodedValues_ListWithMultipleValues() { // Arrange @@ -29,10 +28,10 @@ public void Base64VlqDecoder_MultipleEncodedValues_ListWithMultipleValues() var result = Base64VlqDecoder.Decode(input); // Assert - Assert.Equal(new List { 0, 0, 16, 1 }, result); + Assert.AreEqual(new List { 0, 0, 16, 1 }, result); } - [Fact] + [Test] public void Base64VlqDecoder_InputIncludesNegativeValue_ListContainsNegativeValue() { // Arrange @@ -42,7 +41,7 @@ public void Base64VlqDecoder_InputIncludesNegativeValue_ListContainsNegativeValu var result = Base64VlqDecoder.Decode(input); // Assert - Assert.Equal(new List { 1, 0, 1, -15 }, result); + Assert.AreEqual(new List { 1, 0, 1, -15 }, result); } } } diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/Base64VlqEncoderUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/Base64VlqEncoderUnitTests.cs index 2763420..1aa49f6 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/Base64VlqEncoderUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/Base64VlqEncoderUnitTests.cs @@ -1,12 +1,12 @@ using System.Text; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class Base64VlqEncoderUnitTests { - [Fact] + [Test] public void Base64VlqEncoder_SmallValue_ListWithOnlyOneValue() { // Act @@ -14,10 +14,10 @@ public void Base64VlqEncoder_SmallValue_ListWithOnlyOneValue() Base64VlqEncoder.Encode(result, 15); // Assert - Assert.Equal("e", result.ToString()); + Assert.AreEqual("e", result.ToString()); } - [Fact] + [Test] public void Base64VlqEncoder_LargeValue_ListWithOnlyMultipleValues() { // Act @@ -25,10 +25,10 @@ public void Base64VlqEncoder_LargeValue_ListWithOnlyMultipleValues() Base64VlqEncoder.Encode(result, 701); // Assert - Assert.Equal("6rB", result.ToString()); + Assert.AreEqual("6rB", result.ToString()); } - [Fact] + [Test] public void Base64VlqEncoder_NegativeValue_ListWithCorrectValue() { // Act @@ -36,7 +36,7 @@ public void Base64VlqEncoder_NegativeValue_ListWithCorrectValue() Base64VlqEncoder.Encode(result, -15); // Assert - Assert.Equal("f", result.ToString()); + Assert.AreEqual("f", result.ToString()); } } diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/IReadOnlyListExtensionsUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/IReadOnlyListExtensionsUnitTests.cs index 58868fd..d8bcff6 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/IReadOnlyListExtensionsUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/IReadOnlyListExtensionsUnitTests.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class IReadOnlyListExtensionsUnitTests { - [Fact] + [Test] public void IndexOf_ValueInList_CorrectlyReturnsIndex() { // Arrange @@ -15,10 +15,10 @@ public void IndexOf_ValueInList_CorrectlyReturnsIndex() var index = IReadOnlyListExtensions.IndexOf(list, 1); // Assert - Assert.Equal(2, index); + Assert.AreEqual(2, index); } - [Fact] + [Test] public void IndexOf_ValueNotInList_CorrectlyReturnsNegativeOne() { // Arrange @@ -28,10 +28,10 @@ public void IndexOf_ValueNotInList_CorrectlyReturnsNegativeOne() var index = IReadOnlyListExtensions.IndexOf(list, 1); // Assert - Assert.Equal(-1, index); + Assert.AreEqual(-1, index); } - [Fact] + [Test] public void IndexOf_ValueAppearsMultipleTimes_CorrectlyReturnsFirstInstance() { // Arrange @@ -41,10 +41,10 @@ public void IndexOf_ValueAppearsMultipleTimes_CorrectlyReturnsFirstInstance() var index = IReadOnlyListExtensions.IndexOf(list, 4); // Assert - Assert.Equal(1, index); + Assert.AreEqual(1, index); } - [Fact] + [Test] public void BinarySearch_EvenNumberOfElements_CorrectlyMatchesListImplementation() { // Arrange @@ -63,12 +63,12 @@ public void BinarySearch_EvenNumberOfElements_CorrectlyMatchesListImplementation // Act & Assert for (var i = minFillIndexInclusive - 1; i <= maxFillIndexInclusive + 1; i++) { - Assert.Equal(list.BinarySearch(i, comparer), IReadOnlyListExtensions.BinarySearch(list, i, comparer)); - Assert.Equal(list.BinarySearch(i + 1, comparer), IReadOnlyListExtensions.BinarySearch(list, i + 1, comparer)); + Assert.AreEqual(list.BinarySearch(i, comparer), IReadOnlyListExtensions.BinarySearch(list, i, comparer)); + Assert.AreEqual(list.BinarySearch(i + 1, comparer), IReadOnlyListExtensions.BinarySearch(list, i + 1, comparer)); } } - [Fact] + [Test] public void BinarySearch_OddNumberOfElements_CorrectlyMatchesListImplementation() { // Arrange @@ -87,8 +87,8 @@ public void BinarySearch_OddNumberOfElements_CorrectlyMatchesListImplementation( // Act & Assert for (var i = minFillIndexInclusive - 1; i <= maxFillIndexInclusive + 1; i++) { - Assert.Equal(list.BinarySearch(i, comparer), IReadOnlyListExtensions.BinarySearch(list, i, comparer)); - Assert.Equal(list.BinarySearch(i + 1, comparer), IReadOnlyListExtensions.BinarySearch(list, i + 1, comparer)); + Assert.AreEqual(list.BinarySearch(i, comparer), IReadOnlyListExtensions.BinarySearch(list, i, comparer)); + Assert.AreEqual(list.BinarySearch(i + 1, comparer), IReadOnlyListExtensions.BinarySearch(list, i + 1, comparer)); } } } diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/MappingsListParserUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/MappingsListParserUnitTests.cs index d1dc7df..44f1d3d 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/MappingsListParserUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/MappingsListParserUnitTests.cs @@ -1,14 +1,14 @@  using System; using System.Collections.Generic; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class MappingsListParserUnitTests { - [Fact] + [Test] public void ParseSingleMappingSegment_0SegmentFields_ArgumentOutOfRangeException() { // Arrange @@ -19,7 +19,7 @@ public void ParseSingleMappingSegment_0SegmentFields_ArgumentOutOfRangeException Assert.Throws(() => MappingsListParser.ParseSingleMappingSegment(segmentFields, mappingsParserState)); } - [Fact] + [Test] public void ParseSingleMappingSegment_2SegmentFields_ArgumentOutOfRangeException() { // Arrange @@ -30,7 +30,7 @@ public void ParseSingleMappingSegment_2SegmentFields_ArgumentOutOfRangeException Assert.Throws(() => MappingsListParser.ParseSingleMappingSegment(segmentFields, mappingsParserState)); } - [Fact] + [Test] public void ParseSingleMappingSegment_3SegmentFields_ArgumentOutOfRangeException() { // Arrange @@ -41,7 +41,7 @@ public void ParseSingleMappingSegment_3SegmentFields_ArgumentOutOfRangeException Assert.Throws(() => MappingsListParser.ParseSingleMappingSegment(segmentFields, mappingsParserState)); } - [Fact] + [Test] public void ParseSingleMappingSegment_NoPreviousStateSingleSegment_GeneratedColumnSet() { // Arrange @@ -52,15 +52,15 @@ public void ParseSingleMappingSegment_NoPreviousStateSingleSegment_GeneratedColu var result = MappingsListParser.ParseSingleMappingSegment(segmentFields, mappingsParserState); // Assert - Assert.Equal(0, result.GeneratedLineNumber); - Assert.Equal(16, result.GeneratedColumnNumber); + Assert.AreEqual(0, result.GeneratedLineNumber); + Assert.AreEqual(16, result.GeneratedColumnNumber); Assert.False(result.OriginalSourceFileIndex.HasValue); Assert.False(result.OriginalLineNumber.HasValue); Assert.False(result.OriginalColumnNumber.HasValue); Assert.False(result.OriginalNameIndex.HasValue); } - [Fact] + [Test] public void ParseSingleMappingSegment_NoPreviousState4Segments_OriginalNameIndexNotSetInMappingEntry() { // Arrange @@ -71,15 +71,15 @@ public void ParseSingleMappingSegment_NoPreviousState4Segments_OriginalNameIndex var result = MappingsListParser.ParseSingleMappingSegment(segmentFields, mappingsParserState); // Assert - Assert.Equal(0, result.GeneratedLineNumber); - Assert.Equal(1, result.GeneratedColumnNumber); - Assert.Equal(1, result.OriginalSourceFileIndex); - Assert.Equal(2, result.OriginalLineNumber); - Assert.Equal(4, result.OriginalColumnNumber); + Assert.AreEqual(0, result.GeneratedLineNumber); + Assert.AreEqual(1, result.GeneratedColumnNumber); + Assert.AreEqual(1, result.OriginalSourceFileIndex); + Assert.AreEqual(2, result.OriginalLineNumber); + Assert.AreEqual(4, result.OriginalColumnNumber); Assert.False(result.OriginalNameIndex.HasValue); } - [Fact] + [Test] public void ParseSingleMappingSegment_NoPreviousState5Segments_AllFieldsSetInMappingEntry() { // Arrange @@ -90,15 +90,15 @@ public void ParseSingleMappingSegment_NoPreviousState5Segments_AllFieldsSetInMap var result = MappingsListParser.ParseSingleMappingSegment(segmentFields, mappingsParserState); // Assert - Assert.Equal(0, result.GeneratedLineNumber); - Assert.Equal(1, result.GeneratedColumnNumber); - Assert.Equal(3, result.OriginalSourceFileIndex); - Assert.Equal(6, result.OriginalLineNumber); - Assert.Equal(10, result.OriginalColumnNumber); - Assert.Equal(15, result.OriginalNameIndex); + Assert.AreEqual(0, result.GeneratedLineNumber); + Assert.AreEqual(1, result.GeneratedColumnNumber); + Assert.AreEqual(3, result.OriginalSourceFileIndex); + Assert.AreEqual(6, result.OriginalLineNumber); + Assert.AreEqual(10, result.OriginalColumnNumber); + Assert.AreEqual(15, result.OriginalNameIndex); } - [Fact] + [Test] public void ParseSingleMappingSegment_HasPreviousState5Segments_AllFieldsSetIncrementally() { // Arrange @@ -114,15 +114,15 @@ public void ParseSingleMappingSegment_HasPreviousState5Segments_AllFieldsSetIncr var result = MappingsListParser.ParseSingleMappingSegment(segmentFields, mappingsParserState); // Assert - Assert.Equal(0, result.GeneratedLineNumber); - Assert.Equal(7, result.GeneratedColumnNumber); - Assert.Equal(9, result.OriginalSourceFileIndex); - Assert.Equal(11, result.OriginalLineNumber); - Assert.Equal(13, result.OriginalColumnNumber); - Assert.Equal(15, result.OriginalNameIndex); + Assert.AreEqual(0, result.GeneratedLineNumber); + Assert.AreEqual(7, result.GeneratedColumnNumber); + Assert.AreEqual(9, result.OriginalSourceFileIndex); + Assert.AreEqual(11, result.OriginalLineNumber); + Assert.AreEqual(13, result.OriginalColumnNumber); + Assert.AreEqual(15, result.OriginalNameIndex); } - [Fact] + [Test] public void ParseMappings_SingleSemicolon_GeneratedLineNumberNotIncremented() { // Arrange @@ -134,12 +134,12 @@ public void ParseMappings_SingleSemicolon_GeneratedLineNumberNotIncremented() var mappingsList = MappingsListParser.ParseMappings(mappingsString, names, sources); // Assert - Assert.Equal(2, mappingsList.Count); - Assert.Equal(0, mappingsList[0].GeneratedSourcePosition.Line); - Assert.Equal(0, mappingsList[1].GeneratedSourcePosition.Line); + Assert.AreEqual(2, mappingsList.Count); + Assert.AreEqual(0, mappingsList[0].GeneratedSourcePosition.Line); + Assert.AreEqual(0, mappingsList[1].GeneratedSourcePosition.Line); } - [Fact] + [Test] public void ParseMappings_TwoSemicolons_GeneratedLineNumberIncremented() { // Arrange @@ -151,12 +151,12 @@ public void ParseMappings_TwoSemicolons_GeneratedLineNumberIncremented() var mappingsList = MappingsListParser.ParseMappings(mappingsString, names, sources); // Assert - Assert.Equal(2, mappingsList.Count); - Assert.Equal(0, mappingsList[0].GeneratedSourcePosition.Line); - Assert.Equal(1, mappingsList[1].GeneratedSourcePosition.Line); + Assert.AreEqual(2, mappingsList.Count); + Assert.AreEqual(0, mappingsList[0].GeneratedSourcePosition.Line); + Assert.AreEqual(1, mappingsList[1].GeneratedSourcePosition.Line); } - [Fact] + [Test] public void ParseMappings_BackToBackSemiColons_GeneratedLineNumberIncremented() { // Arrange @@ -168,9 +168,9 @@ public void ParseMappings_BackToBackSemiColons_GeneratedLineNumberIncremented() var mappingsList = MappingsListParser.ParseMappings(mappingsString, names, sources); // Assert - Assert.Equal(2, mappingsList.Count); - Assert.Equal(0, mappingsList[0].GeneratedSourcePosition.Line); - Assert.Equal(2, mappingsList[1].GeneratedSourcePosition.Line); + Assert.AreEqual(2, mappingsList.Count); + Assert.AreEqual(0, mappingsList[0].GeneratedSourcePosition.Line); + Assert.AreEqual(2, mappingsList[1].GeneratedSourcePosition.Line); } } } \ No newline at end of file diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/NumericMappingEntryUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/NumericMappingEntryUnitTests.cs index 2d590a2..64a9548 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/NumericMappingEntryUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/NumericMappingEntryUnitTests.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class NumericMappingEntryUnitTests { - [Fact] + [Test] public void ToMappingEntry_ContainsGeneratedSourcePosition_CorrectMappingEntryFieldsPopulated() { // Arrange @@ -21,14 +21,14 @@ public void ToMappingEntry_ContainsGeneratedSourcePosition_CorrectMappingEntryFi var mappingEntry = numericMappingEntry.ToMappingEntry(names, sources); // Assert - Assert.Equal(12, mappingEntry.GeneratedSourcePosition.Column); - Assert.Equal(13, mappingEntry.GeneratedSourcePosition.Line); - Assert.Equal(SourcePosition.NotFound, mappingEntry.OriginalSourcePosition); + Assert.AreEqual(12, mappingEntry.GeneratedSourcePosition.Column); + Assert.AreEqual(13, mappingEntry.GeneratedSourcePosition.Line); + Assert.AreEqual(SourcePosition.NotFound, mappingEntry.OriginalSourcePosition); Assert.Null(mappingEntry.OriginalFileName); Assert.Null(mappingEntry.OriginalName); } - [Fact] + [Test] public void ToMappingEntry_ContainsGeneratedAndOriginalSourcePosition_CorrectMappingEntryFieldsPopulated() { // Arrange @@ -46,15 +46,15 @@ public void ToMappingEntry_ContainsGeneratedAndOriginalSourcePosition_CorrectMap var mappingEntry = numericMappingEntry.ToMappingEntry(names, sources); // Assert - Assert.Equal(2, mappingEntry.GeneratedSourcePosition.Column); - Assert.Equal(3, mappingEntry.GeneratedSourcePosition.Line); - Assert.Equal(16, mappingEntry.OriginalSourcePosition!.Column); - Assert.Equal(23, mappingEntry.OriginalSourcePosition.Line); + Assert.AreEqual(2, mappingEntry.GeneratedSourcePosition.Column); + Assert.AreEqual(3, mappingEntry.GeneratedSourcePosition.Line); + Assert.AreEqual(16, mappingEntry.OriginalSourcePosition!.Column); + Assert.AreEqual(23, mappingEntry.OriginalSourcePosition.Line); Assert.Null(mappingEntry.OriginalFileName); Assert.Null(mappingEntry.OriginalName); } - [Fact] + [Test] public void ToMappingEntry_ContainsGeneratedPositionNameIndexAndSourcesIndex_CorrectMappingEntryFieldsPopulated() { // Arrange @@ -72,11 +72,11 @@ public void ToMappingEntry_ContainsGeneratedPositionNameIndexAndSourcesIndex_Cor var mappingEntry = numericMappingEntry.ToMappingEntry(names, sources); // Assert - Assert.Equal(8, mappingEntry.GeneratedSourcePosition.Column); - Assert.Equal(48, mappingEntry.GeneratedSourcePosition.Line); - Assert.Equal(SourcePosition.NotFound, mappingEntry.OriginalSourcePosition); - Assert.Equal("three", mappingEntry.OriginalFileName); - Assert.Equal("bar", mappingEntry.OriginalName); + Assert.AreEqual(8, mappingEntry.GeneratedSourcePosition.Column); + Assert.AreEqual(48, mappingEntry.GeneratedSourcePosition.Line); + Assert.AreEqual(SourcePosition.NotFound, mappingEntry.OriginalSourcePosition); + Assert.AreEqual("three", mappingEntry.OriginalFileName); + Assert.AreEqual("bar", mappingEntry.OriginalName); } } } \ No newline at end of file diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapGeneratorUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapGeneratorUnitTests.cs index 5403a62..8b630d3 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapGeneratorUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapGeneratorUnitTests.cs @@ -1,14 +1,14 @@ using System; using System.Collections.Generic; using System.Text; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class SourceMapGeneratorUnitTests { - [Fact] + [Test] public void SerializeMappingEntry_DifferentLineNumber_SemicolonAdded() { // Arrange @@ -29,7 +29,7 @@ public void SerializeMappingEntry_DifferentLineNumber_SemicolonAdded() Assert.True(result.ToString().IndexOf(';') >= 0); } - [Fact] + [Test] public void SerializeMappingEntry_NoOriginalFileName_OneSegment() { // Arrange @@ -45,10 +45,10 @@ public void SerializeMappingEntry_NoOriginalFileName_OneSegment() SourceMapGenerator.SerializeMappingEntry(entry, state, result); // Assert - Assert.Equal("U", result.ToString()); + Assert.AreEqual("U", result.ToString()); } - [Fact] + [Test] public void SerializeMappingEntry_WithOriginalFileNameNoOriginalName_FourSegments() { // Arrange @@ -68,10 +68,10 @@ public void SerializeMappingEntry_WithOriginalFileNameNoOriginalName_FourSegment SourceMapGenerator.SerializeMappingEntry(entry, state, result); // Assert - Assert.Equal(",UAAK", result.ToString()); + Assert.AreEqual(",UAAK", result.ToString()); } - [Fact] + [Test] public void SerializeMappingEntry_WithOriginalFileNameAndOriginalName_FiveSegments() { // Arrange @@ -89,20 +89,10 @@ public void SerializeMappingEntry_WithOriginalFileNameAndOriginalName_FiveSegmen SourceMapGenerator.SerializeMappingEntry(entry, state, result); // Assert - Assert.Equal("KACMA", result.ToString()); + Assert.AreEqual("KACMA", result.ToString()); } - [Fact] - public void SerializeMapping_NullInput_ThrowsException() - { - // Arrange - SourceMap? input = null; - - // Act - Assert.Throws(() => SourceMapGenerator.SerializeMapping(input!)); - } - - [Fact] + [Test] public void SerializeMapping_SimpleSourceMap_CorrectlySerialized() { // Arrange @@ -112,20 +102,10 @@ public void SerializeMapping_SimpleSourceMap_CorrectlySerialized() var output = SourceMapGenerator.SerializeMapping(input); // Assert - Assert.Equal("{\"version\":3,\"file\":\"CommonIntl\",\"mappings\":\"AACAA,aAAA,CAAc;\",\"sources\":[\"input/CommonIntl.js\"],\"names\":[\"CommonStrings\",\"afrikaans\"]}", output); - } - - [Fact] - public void SerializeMappingIntoBast64_NullInput_ThrowsException() - { - // Arrange - SourceMap? input = null; - - // Act - Assert.Throws(() => SourceMapGenerator.GenerateSourceMapInlineComment(input!)); + Assert.AreEqual("{\"version\":3,\"file\":\"CommonIntl\",\"mappings\":\"AACAA,aAAA,CAAc;\",\"sources\":[\"input/CommonIntl.js\"],\"names\":[\"CommonStrings\",\"afrikaans\"]}", output); } - [Fact] + [Test] public void SerializeMappingBase64_SimpleSourceMap_CorrectlySerialized() { // Arrange @@ -135,7 +115,7 @@ public void SerializeMappingBase64_SimpleSourceMap_CorrectlySerialized() var output = SourceMapGenerator.GenerateSourceMapInlineComment(input); // Assert - Assert.Equal("//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ29tbW9uSW50bCIsIm1hcHBpbmdzIjoiQUFDQUEsYUFBQSxDQUFjOyIsInNvdXJjZXMiOlsiaW5wdXQvQ29tbW9uSW50bC5qcyJdLCJuYW1lcyI6WyJDb21tb25TdHJpbmdzIiwiYWZyaWthYW5zIl19", output); + Assert.AreEqual("//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQ29tbW9uSW50bCIsIm1hcHBpbmdzIjoiQUFDQUEsYUFBQSxDQUFjOyIsInNvdXJjZXMiOlsiaW5wdXQvQ29tbW9uSW50bC5qcyJdLCJuYW1lcyI6WyJDb21tb25TdHJpbmdzIiwiYWZyaWthYW5zIl19", output); } private static SourceMap GetSimpleSourceMap() diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapParserUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapParserUnitTests.cs index d256b4d..502db2f 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapParserUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapParserUnitTests.cs @@ -1,12 +1,12 @@ using System.IO; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class SourceMapParserUnitTests { - [Fact] + [Test] public void ParseSourceMap_NullInputStream_ReturnsNull() { // Arrange @@ -19,7 +19,7 @@ public void ParseSourceMap_NullInputStream_ReturnsNull() Assert.Null(output); } - [Fact] + [Test] public void ParseSourceMap_SimpleSourceMap_CorrectlyParsed() { // Arrange @@ -29,14 +29,14 @@ public void ParseSourceMap_SimpleSourceMap_CorrectlyParsed() var output = SourceMapParser.ParseSourceMap(UnitTestUtils.StreamFromString(input))!; // Assert - Assert.Equal(3, output.Version); - Assert.Equal("CommonIntl", output.File); - Assert.Equal("AACAA,aAAA,CAAc", output.Mappings); - Assert.Single(output.Sources); - Assert.Equal("input/CommonIntl.js", output.Sources![0]); - Assert.Equal(2, output.Names!.Count); - Assert.Equal("CommonStrings", output.Names[0]); - Assert.Equal("afrikaans", output.Names[1]); + Assert.AreEqual(3, output.Version); + Assert.AreEqual("CommonIntl", output.File); + Assert.AreEqual("AACAA,aAAA,CAAc", output.Mappings); + Assert.AreEqual(1, output.Sources?.Count); + Assert.AreEqual("input/CommonIntl.js", output.Sources![0]); + Assert.AreEqual(2, output.Names!.Count); + Assert.AreEqual("CommonStrings", output.Names[0]); + Assert.AreEqual("afrikaans", output.Names[1]); } } } diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapTransformerUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapTransformerUnitTests.cs index 1857fef..d526103 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapTransformerUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapTransformerUnitTests.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { @@ -10,7 +10,7 @@ namespace SourcemapToolkit.SourcemapParser.UnitTests public class SourceMapTransformerUnitTests { - [Fact] + [Test] public void FlattenMap_ReturnsOnlyLineInformation() { // Arrange @@ -31,16 +31,16 @@ public void FlattenMap_ReturnsOnlyLineInformation() // Assert Assert.NotNull(linesOnlyMap); - Assert.Single(linesOnlyMap.Sources); - Assert.Single(linesOnlyMap.SourcesContent); - Assert.Single(linesOnlyMap.ParsedMappings); - Assert.Equal(1, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Line); - Assert.Equal(0, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Column); - Assert.Equal(2, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Line); - Assert.Equal(0, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Column); + Assert.AreEqual(1, linesOnlyMap.Sources?.Count); + Assert.AreEqual(1, linesOnlyMap.SourcesContent?.Count); + Assert.AreEqual(1, linesOnlyMap.ParsedMappings.Count); + Assert.AreEqual(1, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Line); + Assert.AreEqual(0, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Column); + Assert.AreEqual(2, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Line); + Assert.AreEqual(0, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Column); } - [Fact] + [Test] public void FlattenMap_MultipleMappingsSameLine_ReturnsOnlyOneMappingPerLine() { // Arrange @@ -66,16 +66,16 @@ public void FlattenMap_MultipleMappingsSameLine_ReturnsOnlyOneMappingPerLine() // Assert Assert.NotNull(linesOnlyMap); - Assert.Single(linesOnlyMap.Sources); - Assert.Single(linesOnlyMap.SourcesContent); - Assert.Single(linesOnlyMap.ParsedMappings); - Assert.Equal(1, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Line); - Assert.Equal(0, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Column); - Assert.Equal(2, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Line); - Assert.Equal(0, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Column); + Assert.AreEqual(1, linesOnlyMap.Sources?.Count); + Assert.AreEqual(1, linesOnlyMap.SourcesContent?.Count); + Assert.AreEqual(1, linesOnlyMap.ParsedMappings.Count); + Assert.AreEqual(1, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Line); + Assert.AreEqual(0, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Column); + Assert.AreEqual(2, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Line); + Assert.AreEqual(0, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Column); } - [Fact] + [Test] public void FlattenMap_MultipleOriginalLineToSameGeneratedLine_ReturnsFirstOriginalLine() { // Arrange @@ -102,13 +102,13 @@ public void FlattenMap_MultipleOriginalLineToSameGeneratedLine_ReturnsFirstOrigi // Assert Assert.NotNull(linesOnlyMap); - Assert.Single(linesOnlyMap.Sources); - Assert.Single(linesOnlyMap.SourcesContent); - Assert.Single(linesOnlyMap.ParsedMappings); - Assert.Equal(1, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Line); - Assert.Equal(0, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Column); - Assert.Equal(2, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Line); - Assert.Equal(0, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Column); + Assert.AreEqual(1, linesOnlyMap.Sources?.Count); + Assert.AreEqual(1, linesOnlyMap.SourcesContent?.Count); + Assert.AreEqual(1, linesOnlyMap.ParsedMappings.Count); + Assert.AreEqual(1, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Line); + Assert.AreEqual(0, linesOnlyMap.ParsedMappings[0].GeneratedSourcePosition.Column); + Assert.AreEqual(2, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Line); + Assert.AreEqual(0, linesOnlyMap.ParsedMappings[0].OriginalSourcePosition!.Column); } } } diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapUnitTests.cs index 0bc070f..917107a 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/SourceMapUnitTests.cs @@ -1,13 +1,13 @@ using System; using System.Collections.Generic; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class SourceMapUnitTests { - [Fact] + [Test] public void GetMappingEntryForGeneratedSourcePosition_NullMappingList_ReturnNull() { // Arrange @@ -21,7 +21,7 @@ public void GetMappingEntryForGeneratedSourcePosition_NullMappingList_ReturnNull Assert.Null(result); } - [Fact] + [Test] public void GetMappingEntryForGeneratedSourcePosition_NoMatchingEntryInMappingList_ReturnNull() { // Arrange @@ -41,7 +41,7 @@ public void GetMappingEntryForGeneratedSourcePosition_NoMatchingEntryInMappingLi Assert.Null(result); } - [Fact] + [Test] public void GetMappingEntryForGeneratedSourcePosition_MatchingEntryInMappingList_ReturnMatchingEntry() { // Arrange @@ -61,10 +61,10 @@ public void GetMappingEntryForGeneratedSourcePosition_MatchingEntryInMappingList var result = sourceMap.GetMappingEntryForGeneratedSourcePosition(sourcePosition); // Asset - Assert.Equal(matchingMappingEntry, result); + Assert.AreEqual(matchingMappingEntry, result); } - [Fact] + [Test] public void GetMappingEntryForGeneratedSourcePosition_NoExactMatchHasSimilarOnSameLine_ReturnSimilarEntry() { // Arrange @@ -83,10 +83,10 @@ public void GetMappingEntryForGeneratedSourcePosition_NoExactMatchHasSimilarOnSa var result = sourceMap.GetMappingEntryForGeneratedSourcePosition(sourcePosition); // Asset - Assert.Equal(matchingMappingEntry, result); + Assert.AreEqual(matchingMappingEntry, result); } - [Fact] + [Test] public void GetMappingEntryForGeneratedSourcePosition_NoExactMatchHasSimilarOnDifferentLinesLine_ReturnSimilarEntry() { // Arrange @@ -105,10 +105,10 @@ public void GetMappingEntryForGeneratedSourcePosition_NoExactMatchHasSimilarOnDi var result = sourceMap.GetMappingEntryForGeneratedSourcePosition(sourcePosition); // Asset - Assert.Equal(matchingMappingEntry, result); + Assert.AreEqual(matchingMappingEntry, result); } - [Fact] + [Test] public void GetRootMappingEntryForGeneratedSourcePosition_NoChildren_ReturnsSameEntry() { // Arrange @@ -124,30 +124,10 @@ public void GetRootMappingEntryForGeneratedSourcePosition_NoChildren_ReturnsSame var rootEntry = sourceMap.GetMappingEntryForGeneratedSourcePosition(generated1); // Assert - Assert.Equal(rootEntry, mappingEntry); + Assert.AreEqual(rootEntry, mappingEntry); } - [Fact] - public void ApplyMap_NullSubmap_ThrowsException() - { - // Arrange - var generated2 = UnitTestUtils.GenerateSourcePosition(lineNumber: 3, colNumber: 5); - var original2 = UnitTestUtils.GenerateSourcePosition(lineNumber: 2, colNumber: 5); - var mapping = UnitTestUtils.GetSimpleEntry(generated2, original2, "sourceOne.js"); - - var map = CreateSourceMap( - file: "generated.js", - sources: new List() { "sourceOne.js" }, - parsedMappings: new List { mapping }); - - - // Act - Assert.Throws(() => map.ApplySourceMap(null!)); - - // Assert (decorated expected exception) - } - - [Fact] + [Test] public void ApplyMap_NoMatchingSources_ReturnsSameMap() { // Arrange @@ -178,7 +158,7 @@ public void ApplyMap_NoMatchingSources_ReturnsSameMap() Assert.True(firstMapping.IsValueEqual(parentMapping)); } - [Fact] + [Test] public void ApplyMap_NoMatchingMappings_ReturnsSameMap() { // Arrange @@ -209,7 +189,7 @@ public void ApplyMap_NoMatchingMappings_ReturnsSameMap() Assert.True(firstMapping.IsValueEqual(parentMapping)); } - [Fact] + [Test] public void ApplyMap_MatchingSources_ReturnsCorrectMap() { // Expect mapping with same source filename as the applied source-map to be replaced @@ -238,13 +218,13 @@ public void ApplyMap_MatchingSources_ReturnsCorrectMap() // Assert Assert.NotNull(combinedMap); - Assert.Single(combinedMap.ParsedMappings); - Assert.Single(combinedMap.Sources); + Assert.AreEqual(1, combinedMap.ParsedMappings.Count); + Assert.AreEqual(1, combinedMap.Sources?.Count); var rootMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated2)!; - Assert.Equal(0, rootMapping.Value.OriginalSourcePosition!.CompareTo(childMapping.OriginalSourcePosition!)); + Assert.AreEqual(0, rootMapping.Value.OriginalSourcePosition!.CompareTo(childMapping.OriginalSourcePosition!)); } - [Fact] + [Test] public void ApplyMap_PartialMatchingSources_ReturnsCorrectMap() { // Expect mappings with same source filename as the applied source-map to be replaced @@ -278,15 +258,15 @@ public void ApplyMap_PartialMatchingSources_ReturnsCorrectMap() // Assert Assert.NotNull(combinedMap); - Assert.Equal(2, combinedMap.ParsedMappings.Count); - Assert.Equal(2, combinedMap.Sources!.Count); + Assert.AreEqual(2, combinedMap.ParsedMappings.Count); + Assert.AreEqual(2, combinedMap.Sources!.Count); var firstCombinedMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated3)!; Assert.True(firstCombinedMapping.Value.IsValueEqual(mapping2)); var secondCombinedMapping = combinedMap.GetMappingEntryForGeneratedSourcePosition(generated2)!; - Assert.Equal(0, secondCombinedMapping.Value.OriginalSourcePosition!.CompareTo(childMapping.OriginalSourcePosition!)); + Assert.AreEqual(0, secondCombinedMapping.Value.OriginalSourcePosition!.CompareTo(childMapping.OriginalSourcePosition!)); } - [Fact] + [Test] public void ApplyMap_ExactMatchDeep_ReturnsCorrectMappingEntry() { // Arrange @@ -325,7 +305,7 @@ public void ApplyMap_ExactMatchDeep_ReturnsCorrectMappingEntry() var secondCombinedMap = firstCombinedMap.ApplySourceMap(grandChildMap); Assert.NotNull(secondCombinedMap); var rootMapping = secondCombinedMap.GetMappingEntryForGeneratedSourcePosition(generated3)!; - Assert.Equal(0, rootMapping.Value.OriginalSourcePosition!.CompareTo(mapLevel2.OriginalSourcePosition!)); + Assert.AreEqual(0, rootMapping.Value.OriginalSourcePosition!.CompareTo(mapLevel2.OriginalSourcePosition!)); } private static SourceMap CreateSourceMap( diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/SourcePositionUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/SourcePositionUnitTests.cs index 27e0a00..dfd3a6e 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/SourcePositionUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/SourcePositionUnitTests.cs @@ -1,11 +1,11 @@ -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class SourcePositionUnitTests { - [Fact] + [Test] public void CompareTo_SameLineAndColumn_Equal() { // Arrange @@ -16,10 +16,10 @@ public void CompareTo_SameLineAndColumn_Equal() var result = x.CompareTo(y); // Assert - Assert.Equal(0, result); + Assert.AreEqual(0, result); } - [Fact] + [Test] public void CompareTo_LargerZeroBasedLineNumber_ReturnLarger() { // Arrange @@ -33,7 +33,7 @@ public void CompareTo_LargerZeroBasedLineNumber_ReturnLarger() Assert.True(result > 0); } - [Fact] + [Test] public void CompareTo_SmallerZeroBasedLineNumber_ReturnSmaller() { // Arrange @@ -47,7 +47,7 @@ public void CompareTo_SmallerZeroBasedLineNumber_ReturnSmaller() Assert.True(result < 0); } - [Fact] + [Test] public void CompareTo_SameLineLargerColumn_ReturnLarger() { // Arrange @@ -61,7 +61,7 @@ public void CompareTo_SameLineLargerColumn_ReturnLarger() Assert.True(result > 0); } - [Fact] + [Test] public void CompareTo_SameLineSmallerColumn_ReturnSmaller() { // Arrange @@ -75,7 +75,7 @@ public void CompareTo_SameLineSmallerColumn_ReturnSmaller() Assert.True(result < 0); } - [Fact] + [Test] public void LessThanOverload_SameZeroBasedLineNumberXColumnSmaller_ReturnTrue() { // Arrange @@ -89,7 +89,7 @@ public void LessThanOverload_SameZeroBasedLineNumberXColumnSmaller_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void LessThanOverload_XZeroBasedLineNumberSmallerX_ReturnTrue() { // Arrange @@ -103,7 +103,7 @@ public void LessThanOverload_XZeroBasedLineNumberSmallerX_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void LessThanOverload_Equal_ReturnFalse() { // Arrange @@ -117,7 +117,7 @@ public void LessThanOverload_Equal_ReturnFalse() Assert.False(result); } - [Fact] + [Test] public void LessThanOverload_XColumnLarger_ReturnFalse() { // Arrange @@ -131,7 +131,7 @@ public void LessThanOverload_XColumnLarger_ReturnFalse() Assert.False(result); } - [Fact] + [Test] public void GreaterThanOverload_SameLineXColumnLarger_ReturnTrue() { // Arrange @@ -145,7 +145,7 @@ public void GreaterThanOverload_SameLineXColumnLarger_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void GreaterThanOverload_XZeroBasedLineNumberLarger_ReturnTrue() { // Arrange @@ -159,7 +159,7 @@ public void GreaterThanOverload_XZeroBasedLineNumberLarger_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void GreaterThanOverload_Equal_ReturnFalse() { // Arrange @@ -173,7 +173,7 @@ public void GreaterThanOverload_Equal_ReturnFalse() Assert.False(result); } - [Fact] + [Test] public void GreaterThanOverload_XSmaller_ReturnFalse() { // Arrange @@ -187,7 +187,7 @@ public void GreaterThanOverload_XSmaller_ReturnFalse() Assert.False(result); } - [Fact] + [Test] public void IsEqualish_XEqualsY_ReturnTrue() { // Arrange @@ -201,7 +201,7 @@ public void IsEqualish_XEqualsY_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void IsEqualish_XColumnNumberBiggerByOne_ReturnTrue() { // Arrange @@ -215,7 +215,7 @@ public void IsEqualish_XColumnNumberBiggerByOne_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void IsEqualish_YColumnNumberBiggerByOne_ReturnTrue() { // Arrange @@ -229,7 +229,7 @@ public void IsEqualish_YColumnNumberBiggerByOne_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void IsEqualish_YColumnNumberBiggerByTwo_ReturnFalse() { // Arrange @@ -243,7 +243,7 @@ public void IsEqualish_YColumnNumberBiggerByTwo_ReturnFalse() Assert.False(result); } - [Fact] + [Test] public void IsEqualish_XColumnNumberZeroLineNumbersDifferByOne_ReturnTrue() { // Arrange @@ -257,7 +257,7 @@ public void IsEqualish_XColumnNumberZeroLineNumbersDifferByOne_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void IsEqualish_YColumnNumberZeroLineNumbersDifferByOne_ReturnTrue() { // Arrange @@ -271,7 +271,7 @@ public void IsEqualish_YColumnNumberZeroLineNumbersDifferByOne_ReturnTrue() Assert.True(result); } - [Fact] + [Test] public void IsEqualish_YColumnNumberZeroLineNumbersDifferByTwo_ReturnFalse() { // Arrange diff --git a/tests/SourcemapTools.UnitTests/SourcemapParser/StringExtensionsUnitTests.cs b/tests/SourcemapTools.UnitTests/SourcemapParser/StringExtensionsUnitTests.cs index c7012eb..eca3624 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapParser/StringExtensionsUnitTests.cs +++ b/tests/SourcemapTools.UnitTests/SourcemapParser/StringExtensionsUnitTests.cs @@ -1,28 +1,11 @@ using System; -using Xunit; +using NUnit.Framework; namespace SourcemapToolkit.SourcemapParser.UnitTests { public class StringExtensionsUnitTests { - [Fact] - public void SplitFast_NullInput_Throws() - { - // Arrange - const string? input = null; - const char delimiter = ','; - - // Act - static void testAction() - { - StringExtensions.SplitFast(input!, delimiter); - } - - //Throws Assert - Assert.Throws(testAction); - } - - [Fact] + [Test] public void SplitFast_EmptyInput_Matches() { // Arrange @@ -34,15 +17,15 @@ public void SplitFast_EmptyInput_Matches() var normalSplit = input.Split(delimiter); // Assert - Assert.Equal(normalSplit.Length, fastSplit.Length); + Assert.AreEqual(normalSplit.Length, fastSplit.Length); for (var i = 0; i < normalSplit.Length; i++) { - Assert.Equal(normalSplit[i], fastSplit[i]); + Assert.AreEqual(normalSplit[i], fastSplit[i]); } } - [Fact] + [Test] public void SplitFast_OneCharacterNotSplit_Matches() { // Arrange @@ -54,15 +37,15 @@ public void SplitFast_OneCharacterNotSplit_Matches() var normalSplit = input.Split(delimiter); // Assert - Assert.Equal(normalSplit.Length, fastSplit.Length); + Assert.AreEqual(normalSplit.Length, fastSplit.Length); for (var i = 0; i < normalSplit.Length; i++) { - Assert.Equal(normalSplit[i], fastSplit[i]); + Assert.AreEqual(normalSplit[i], fastSplit[i]); } } - [Fact] + [Test] public void SplitFast_OneCharacterDelimiter_Matches() { // Arrange @@ -74,15 +57,15 @@ public void SplitFast_OneCharacterDelimiter_Matches() var normalSplit = input.Split(delimiter); // Assert - Assert.Equal(normalSplit.Length, fastSplit.Length); + Assert.AreEqual(normalSplit.Length, fastSplit.Length); for (var i = 0; i < normalSplit.Length; i++) { - Assert.Equal(normalSplit[i], fastSplit[i]); + Assert.AreEqual(normalSplit[i], fastSplit[i]); } } - [Fact] + [Test] public void SplitFast_DelimiterAtStart_Matches() { // Arrange @@ -94,15 +77,15 @@ public void SplitFast_DelimiterAtStart_Matches() var normalSplit = input.Split(delimiter); // Assert - Assert.Equal(normalSplit.Length, fastSplit.Length); + Assert.AreEqual(normalSplit.Length, fastSplit.Length); for (var i = 0; i < normalSplit.Length; i++) { - Assert.Equal(normalSplit[i], fastSplit[i]); + Assert.AreEqual(normalSplit[i], fastSplit[i]); } } - [Fact] + [Test] public void SplitFast_DelimiterAtEnd_Matches() { // Arrange @@ -114,15 +97,15 @@ public void SplitFast_DelimiterAtEnd_Matches() var normalSplit = input.Split(delimiter); // Assert - Assert.Equal(normalSplit.Length, fastSplit.Length); + Assert.AreEqual(normalSplit.Length, fastSplit.Length); for (var i = 0; i < normalSplit.Length; i++) { - Assert.Equal(normalSplit[i], fastSplit[i]); + Assert.AreEqual(normalSplit[i], fastSplit[i]); } } - [Fact] + [Test] public void SplitFast_BackToBack_Matches() { // Arrange @@ -134,15 +117,15 @@ public void SplitFast_BackToBack_Matches() var normalSplit = input.Split(delimiter); // Assert - Assert.Equal(normalSplit.Length, fastSplit.Length); + Assert.AreEqual(normalSplit.Length, fastSplit.Length); for (var i = 0; i < normalSplit.Length; i++) { - Assert.Equal(normalSplit[i], fastSplit[i]); + Assert.AreEqual(normalSplit[i], fastSplit[i]); } } - [Fact] + [Test] public void SplitFast_LongSentence_Matches() { // Arrange @@ -154,15 +137,15 @@ public void SplitFast_LongSentence_Matches() var normalSplit = input.Split(delimiter); // Assert - Assert.Equal(normalSplit.Length, fastSplit.Length); + Assert.AreEqual(normalSplit.Length, fastSplit.Length); for (var i = 0; i < normalSplit.Length; i++) { - Assert.Equal(normalSplit[i], fastSplit[i]); + Assert.AreEqual(normalSplit[i], fastSplit[i]); } } - [Fact] + [Test] public void SplitFast_Complex_Matches() { // Arrange @@ -174,11 +157,11 @@ public void SplitFast_Complex_Matches() var normalSplit = input.Split(delimiter); // Assert - Assert.Equal(normalSplit.Length, fastSplit.Length); + Assert.AreEqual(normalSplit.Length, fastSplit.Length); for (var i = 0; i < normalSplit.Length; i++) { - Assert.Equal(normalSplit[i], fastSplit[i]); + Assert.AreEqual(normalSplit[i], fastSplit[i]); } } } diff --git a/tests/SourcemapTools.UnitTests/SourcemapTools.UnitTests.csproj b/tests/SourcemapTools.UnitTests/SourcemapTools.UnitTests.csproj index 4c24019..7adbf26 100644 --- a/tests/SourcemapTools.UnitTests/SourcemapTools.UnitTests.csproj +++ b/tests/SourcemapTools.UnitTests/SourcemapTools.UnitTests.csproj @@ -5,10 +5,10 @@ net48;netcoreapp2.1;netcoreapp3.1;net5.0; - - - - + + + +