public bool Parse(StackTrace stackTrace) { foreach (IStackTraceParser p in GetParsers()) { if (p.Parse(stackTrace)) { parser = p; return true; } } var helpLink = @"http://blog.approvaltests.com/2012/01/creating-namers.html"; throw new Exception( string.Format("Approvals is not set up to use your test framework.{0}" + "It currently supports {1}{0}" + "To add one use {2}.AddParser() method to add implementation of {3} with support for your testing framework.{0}" + "To learn how to implement one see {4}", Environment.NewLine, ForTestingFramework, GetType(), typeof (IStackTraceParser), helpLink)) { HelpLink = helpLink }; }
public void DeminifyStackTrace_AbleToDeminifyStackTrace_ResultContainsDeminifiedFrame() { // Arrange IStackTraceParser stackTraceParser = MockRepository.GenerateStrictMock <IStackTraceParser>(); List <StackFrame> minifiedStackFrames = new List <StackFrame> { new StackFrame() }; string stackTraceString = "foobar"; stackTraceParser.Stub(x => x.ParseStackTrace(stackTraceString, out string message)).Return(minifiedStackFrames).OutRef("Error example"); IStackFrameDeminifier stackFrameDeminifier = MockRepository.GenerateStrictMock <IStackFrameDeminifier>(); StackFrameDeminificationResult stackFrameDeminification = new StackFrameDeminificationResult(); stackFrameDeminifier.Stub(x => x.DeminifyStackFrame(minifiedStackFrames[0], null)).Return(stackFrameDeminification); StackTraceDeminifier stackTraceDeminifier = new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser); // Act DeminifyStackTraceResult result = stackTraceDeminifier.DeminifyStackTrace(stackTraceString); // Assert Assert.Equal(1, result.DeminifiedStackFrameResults.Count); Assert.Equal(minifiedStackFrames[0], result.MinifiedStackFrames[0]); Assert.Equal(stackFrameDeminification, result.DeminifiedStackFrameResults[0]); }
public void DeminifyStackTrace_UnableToDeminifyStackTrace_ResultContainsNullDeminifiedFrame() { // Arrange IStackTraceParser stackTraceParser = MockRepository.GenerateStrictMock <IStackTraceParser>(); List <StackFrame> minifiedStackFrames = new List <StackFrame> { new StackFrame() }; string stackTraceString = "foobar"; stackTraceParser.Stub(x => x.ParseStackTrace(stackTraceString)).Return(minifiedStackFrames); IStackFrameDeminifier stackFrameDeminifier = MockRepository.GenerateStrictMock <IStackFrameDeminifier>(); stackFrameDeminifier.Stub(x => x.DeminifyStackFrame(minifiedStackFrames[0])).Return(null); StackTraceDeminifier stackTraceDeminifier = new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser); // Act DeminifyStackTraceResult result = stackTraceDeminifier.DeminifyStackTrace(stackTraceString); // Assert Assert.AreEqual(1, result.DeminifiedStackFrameResults.Count); Assert.AreEqual(minifiedStackFrames[0], result.MinifiedStackFrames[0]); Assert.IsNull(result.DeminifiedStackFrameResults[0]); }
public bool Parse(StackTrace stackTrace) { foreach (IStackTraceParser p in GetParsers()) { if (p.Parse(stackTrace)) { parser = p; return(true); } } var helpLink = @"http://blog.approvaltests.com/2012/01/creating-namers.html"; throw new Exception( string.Format("Approvals is not set up to use your test framework.{0}" + "It currently supports {1}{0}" + "To add one use {2}.AddParser() method to add implementation of {3} with support for your testing framework.{0}" + "To learn how to implement one see {4}", Environment.NewLine, ForTestingFramework, GetType(), typeof(IStackTraceParser), helpLink)) { HelpLink = helpLink }; }
public bool Parse(StackTrace stackTrace) { foreach (IStackTraceParser p in getParsers()) { if (p.Parse(stackTrace)) { parser = p; return true; } } throw new Exception(string.Format("Could Find Namer for {0}", stackTrace)); }
public bool Parse(StackTrace stackTrace) { foreach (IStackTraceParser p in getParsers()) { if (p.Parse(stackTrace)) { parser = p; return(true); } } throw new Exception(string.Format("Could Find Namer for {0}", stackTrace)); }
public void DeminifyStackTrace_UnableToParseStackTraceString_ReturnsEmptyList() { // Arrange IStackTraceParser stackTraceParser = MockRepository.GenerateStrictMock <IStackTraceParser>(); string stackTraceString = "foobar"; stackTraceParser.Stub(x => x.ParseStackTrace(stackTraceString, out string message)).Return(new List <StackFrame>()).OutRef("Error example"); IStackFrameDeminifier stackFrameDeminifier = MockRepository.GenerateStrictMock <IStackFrameDeminifier>(); StackTraceDeminifier stackTraceDeminifier = new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser); // Act DeminifyStackTraceResult result = stackTraceDeminifier.DeminifyStackTrace(stackTraceString); // Assert Assert.Equal(0, result.DeminifiedStackFrameResults.Count); }
public bool Parse(StackTrace stackTrace) { foreach (IStackTraceParser parserTemplate in GetParsers()) { IStackTraceParser p = (IStackTraceParser)Activator.CreateInstance(parserTemplate.GetType()); if (p.Parse(stackTrace)) { parser = p; return(true); } } var helpLink = @"http://blog.approvaltests.com/2012/01/creating-namers.html"; throw new Exception( string.Format(@" Could Not Detect Test Framework Either: 1) Optimizer Inlined Test Methods Solutions: a) Add [MethodImpl(MethodImplOptions.NoInlining)] b) Set Build->Optimize Code to False & Build->Advanced->DebugInfo to Full or 2) Approvals is not set up to use your test framework. It currently supports {0} Solution: To add one use {1}.AddParser() method to add implementation of {2} with support for your testing framework. To learn how to implement one see {3}", ForTestingFramework, GetType(), typeof(IStackTraceParser), helpLink)) { HelpLink = helpLink }; }
public bool Parse(StackTrace stackTrace) { foreach (IStackTraceParser parserTemplate in GetParsers()) { IStackTraceParser p = (IStackTraceParser) Activator.CreateInstance(parserTemplate.GetType()); if (p.Parse(stackTrace)) { parser = p; return true; } } var helpLink = @"http://blog.approvaltests.com/2012/01/creating-namers.html"; throw new Exception( string.Format(@" Could Not Detect Test Framework Either: 1) Optimizer Inlined Test Methods Solutions: a) Add [MethodImpl(MethodImplOptions.NoInlining)] b) Set Build->Optimize Code to False & Build->Advanced->DebugInfo to Full or 2) Approvals is not set up to use your test framework. It currently supports {0} Solution: To add one use {1}.AddParser() method to add implementation of {2} with support for your testing framework. To learn how to implement one see {3}", ForTestingFramework, GetType(), typeof(IStackTraceParser), helpLink)) { HelpLink = helpLink }; }
public static void AddParser(IStackTraceParser parser) { parsers.Add(parser); }
internal StackTraceDeminifier(IStackFrameDeminifier stackFrameDeminifier, IStackTraceParser stackTraceParser) { _stackFrameDeminifier = stackFrameDeminifier; _stackTraceParser = stackTraceParser; }
public static void AddParser(IStackTraceParser parser) { parsers.Add(parser); }
private static void ValidateArguments(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider, IStackTraceParser stackTraceParser) { if (sourceMapProvider == null) { throw new ArgumentNullException(nameof(sourceMapProvider)); } if (generatedCodeProvider == null) { throw new ArgumentNullException(nameof(generatedCodeProvider)); } if (stackTraceParser == null) { throw new ArgumentNullException(nameof(stackTraceParser)); } }
/// <summary> /// Creates a StackTraceDeminifier which does not depend on JS files, and is ES2015+ compatible. /// StackTrace deminifiers created with this method will keep source maps cached, and thus use significantly more memory during runtime than the ones generated with GetMethodNameOnlyStackTraceDeminfier. /// </summary> /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param> public static StackTraceDeminifier GetMapOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider, IStackTraceParser stackTraceParser) { if (sourceMapProvider == null) { throw new ArgumentNullException(nameof(sourceMapProvider)); } if (stackTraceParser == null) { throw new ArgumentNullException(nameof(stackTraceParser)); } ISourceMapStore sourceMapStore = new SourceMapStore(sourceMapProvider); IStackFrameDeminifier stackFrameDeminifier = new StackFrameDeminifier(sourceMapStore); return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser)); }
/// <summary> /// Creates a StackTraceDeminifier with full capabilities. StackTrace deminifiers created with this method will keep source maps cached, and thus use significantly more memory during runtime than the ones generated with GetMethodNameOnlyStackTraceDeminfier. /// </summary> /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="generatedCodeProvider">Consumers of the API should implement this interface, which provides the contents of a JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param> public static StackTraceDeminifier GetStackTraceDeminfier(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider, IStackTraceParser stackTraceParser) { ValidateArguments(sourceMapProvider, generatedCodeProvider, stackTraceParser); ISourceMapStore sourceMapStore = new SourceMapStore(sourceMapProvider); IStackFrameDeminifier stackFrameDeminifier = new StackFrameDeminifier(sourceMapStore, new FunctionMapStore(generatedCodeProvider, sourceMapStore.GetSourceMapForUrl), new FunctionMapConsumer()); return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser)); }
/// <summary> /// Creates a StackTraceDeminifier that only deminifies the method names. StackTrace deminifiers created with this method will use significantly less memory during runtime than the /// </summary> /// <param name="sourceMapProvider">Consumers of the API should implement this interface, which provides the source map for a given JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="generatedCodeProvider">Consumers of the API should implement this interface, which provides the contents of a JavaScript file. Throws ArgumentNullException if the parameter is set to null.</param> /// <param name="stackTraceParser">Consumers of the API should implement this interface, which provides a parser for the stacktrace. Throws ArgumentNullException if the parameter is set to null.</param> public static StackTraceDeminifier GetMethodNameOnlyStackTraceDeminfier(ISourceMapProvider sourceMapProvider, ISourceCodeProvider generatedCodeProvider, IStackTraceParser stackTraceParser) { ValidateArguments(sourceMapProvider, generatedCodeProvider, stackTraceParser); SourceMapParser sourceMapParser = new SourceMapParser(); IStackFrameDeminifier stackFrameDeminifier = new MethodNameStackFrameDeminifier(new FunctionMapStore(generatedCodeProvider, (url) => sourceMapParser.ParseSourceMap(sourceMapProvider.GetSourceMapContentsForCallstackUrl(url))), new FunctionMapConsumer()); return(new StackTraceDeminifier(stackFrameDeminifier, stackTraceParser)); }