Beispiel #1
0
        public void SimpleStackFrameDeminierDeminifyStackFrame_GetWRappingFunctionForSourceLocationReturnsNull_NoWrapingFunctionDeminificationError()
        {
            // Arrange
            string     filePath   = "foo";
            StackFrame stackFrame = new StackFrame {
                FilePath = filePath
            };
            IFunctionMapStore functionMapStore = MockRepository.GenerateStub <IFunctionMapStore>();

            functionMapStore.Stub(c => c.GetFunctionMapForSourceCode(filePath))
            .Return(new List <FunctionMapEntry>());
            IFunctionMapConsumer functionMapConsumer = MockRepository.GenerateStub <IFunctionMapConsumer>();

            functionMapConsumer.Stub(c => c.GetWrappingFunctionForSourceLocation(Arg <SourcePosition> .Is.Anything, Arg <List <FunctionMapEntry> > .Is.Anything))
            .Return(null);

            IStackFrameDeminifier stackFrameDeminifier = GetStackFrameDeminifierWithMockDependencies(functionMapStore: functionMapStore, functionMapConsumer: functionMapConsumer, useSimpleStackFrameDeminier: true);

            // Act
            StackFrameDeminificationResult stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null);

            // Assert
            Assert.Equal(DeminificationError.NoWrapingFunctionFound, stackFrameDeminification.DeminificationError);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.MethodName);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.SourcePosition);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath);
        }
Beispiel #2
0
        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]);
        }
Beispiel #3
0
        public void StackFrameDeminierDeminifyStackFrame_SourceMapParsingNull_SourceMapFailedToParseError()
        {
            // Arrange
            string           filePath = "foo";
            FunctionMapEntry wrapingFunctionMapEntry = new FunctionMapEntry {
                DeminfifiedMethodName = "DeminifiedFoo"
            };
            StackFrame stackFrame = new StackFrame {
                FilePath = filePath
            };
            IFunctionMapStore functionMapStore = MockRepository.GenerateStub <IFunctionMapStore>();

            functionMapStore.Stub(c => c.GetFunctionMapForSourceCode(filePath))
            .Return(new List <FunctionMapEntry>());
            IFunctionMapConsumer functionMapConsumer = MockRepository.GenerateStub <IFunctionMapConsumer>();

            functionMapConsumer.Stub(c => c.GetWrappingFunctionForSourceLocation(Arg <SourcePosition> .Is.Anything, Arg <List <FunctionMapEntry> > .Is.Anything))
            .Return(wrapingFunctionMapEntry);
            ISourceMapStore sourceMapStore = MockRepository.GenerateStub <ISourceMapStore>();

            sourceMapStore.Stub(c => c.GetSourceMapForUrl(Arg <string> .Is.Anything)).Return(new SourceMap());

            IStackFrameDeminifier stackFrameDeminifier = GetStackFrameDeminifierWithMockDependencies(sourceMapStore: sourceMapStore, functionMapStore: functionMapStore, functionMapConsumer: functionMapConsumer);

            // Act
            StackFrameDeminificationResult stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null);

            // Assert
            Assert.Equal(DeminificationError.SourceMapFailedToParse, stackFrameDeminification.DeminificationError);
            Assert.Equal(wrapingFunctionMapEntry.DeminfifiedMethodName, stackFrameDeminification.DeminifiedStackFrame.MethodName);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.SourcePosition);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath);
        }
Beispiel #4
0
        public void DeminifyStackTrace_AbleToDeminifyStackTrace_ResultContainsDeminifiedFrame()
        {
            // Arrange
            var stackTraceParserMock = new Mock <IStackTraceParser>();
            var minifiedStackFrames  = new List <StackFrame> {
                new StackFrame(null, null, null)
            };
            var stackTraceString = "foobar";

            stackTraceParserMock
            .Setup(x => x.ParseStackTrace(stackTraceString))
            .Returns(minifiedStackFrames);

            var stackFrameDeminifierMock = new Mock <IStackFrameDeminifier>();
            var stackFrameDeminification = StackFrameDeminificationResult.Ok(null);

            stackFrameDeminifierMock
            .Setup(x => x.DeminifyStackFrame(minifiedStackFrames[0]))
            .Returns(stackFrameDeminification);

            var stackTraceDeminifier = new StackTraceDeminifier(
                stackFrameDeminifierMock.Object, stackTraceParserMock.Object);

            // Act
            var result = stackTraceDeminifier.DeminifyStackTrace(stackTraceString);

            // Assert
            Assert.AreEqual(1, result.DeminifiedStackFrameResults.Count);
            Assert.AreEqual(minifiedStackFrames[0], result.MinifiedStackFrames[0]);
            Assert.AreEqual(stackFrameDeminification, result.DeminifiedStackFrameResults[0]);
        }
Beispiel #5
0
        public void DeminifyStackFrame_NullInputStackFrame_ThrowsException()
        {
            // Arrange
            IStackFrameDeminifier stackFrameDeminifier = GetStackFrameDeminifierWithMockDependencies();
            StackFrame            stackFrame           = null;

            // Act
            StackFrameDeminificationResult stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame);
        }
Beispiel #6
0
        public void DeminifyStackFrame_StackFrameNullProperties_DoesNotThrowException()
        {
            // Arrange
            StackFrame            stackFrame           = new StackFrame();
            IStackFrameDeminifier stackFrameDeminifier = GetStackFrameDeminifierWithMockDependencies();

            // Act
            StackFrameDeminificationResult stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null);

            // Assert
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.MethodName);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.SourcePosition);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath);
        }
Beispiel #7
0
        public void SimpleStackFrameDeminierDeminifyStackFrame_FunctionMapReturnsNull_NoFunctionMapDeminificationError()
        {
            // Arrange
            string     filePath   = "foo";
            StackFrame stackFrame = new StackFrame {
                FilePath = filePath
            };
            IFunctionMapStore functionMapStore = MockRepository.GenerateStub <IFunctionMapStore>();

            functionMapStore.Stub(c => c.GetFunctionMapForSourceCode(filePath))
            .Return(null);

            IStackFrameDeminifier stackFrameDeminifier = GetStackFrameDeminifierWithMockDependencies(functionMapStore: functionMapStore, useSimpleStackFrameDeminier: true);

            // Act
            StackFrameDeminificationResult stackFrameDeminification = stackFrameDeminifier.DeminifyStackFrame(stackFrame, callerSymbolName: null);

            // Assert
            Assert.Equal(DeminificationError.NoSourceCodeProvided, stackFrameDeminification.DeminificationError);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.MethodName);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.SourcePosition);
            Assert.Null(stackFrameDeminification.DeminifiedStackFrame.FilePath);
        }