示例#1
0
        public void GetDeminifiedMethodNameFromSourceMap_MatchingMappingMultipleBindings_ReturnsMethodNameWithFullBinding()
        {
            // Arrange
            FunctionMapEntry functionMapEntry = new FunctionMapEntry
            {
                Bindings =
                    new List <BindingInformation>
                {
                    new BindingInformation
                    {
                        SourcePosition = new SourcePosition {
                            ZeroBasedLineNumber = 5, ZeroBasedColumnNumber = 5
                        }
                    },
                    new BindingInformation
                    {
                        SourcePosition = new SourcePosition {
                            ZeroBasedLineNumber = 20, ZeroBasedColumnNumber = 10
                        }
                    }
                }
            };

            SourceMap sourceMap = MockRepository.GenerateStub <SourceMap>();

            sourceMap.Stub(
                x =>
                x.GetMappingEntryForGeneratedSourcePosition(
                    Arg <SourcePosition> .Matches(y => y.ZeroBasedLineNumber == 5 && y.ZeroBasedColumnNumber == 5)))
            .Return(new MappingEntry
            {
                OriginalName = "bar"
            });

            sourceMap.Stub(
                x =>
                x.GetMappingEntryForGeneratedSourcePosition(
                    Arg <SourcePosition> .Matches(y => y.ZeroBasedLineNumber == 20 && y.ZeroBasedColumnNumber == 10)))
            .Return(new MappingEntry
            {
                OriginalName = "baz",
            });

            // Act
            string result = FunctionMapGenerator.GetDeminifiedMethodNameFromSourceMap(functionMapEntry, sourceMap);

            // Assert
            Assert.AreEqual("bar.baz", result);
            sourceMap.VerifyAllExpectations();
        }
示例#2
0
        public void GetDeminifiedMethodNameFromSourceMap_HasSingleBindingNoMatchingMapping_ReturnNullMethodName()
        {
            // Arrange
            FunctionMapEntry functionMapEntry = new FunctionMapEntry
            {
                Bindings =
                    new List <BindingInformation>
                {
                    new BindingInformation
                    {
                        SourcePosition = new SourcePosition {
                            ZeroBasedLineNumber = 20, ZeroBasedColumnNumber = 15
                        }
                    }
                }
            };

            SourceMap sourceMap = MockRepository.GenerateStub <SourceMap>();

            sourceMap.Stub(x => x.GetMappingEntryForGeneratedSourcePosition(Arg <SourcePosition> .Is.Anything)).Return(null);

            // Act
            string result = FunctionMapGenerator.GetDeminifiedMethodNameFromSourceMap(functionMapEntry, sourceMap);

            // Assert
            Assert.IsNull(result);
            sourceMap.VerifyAllExpectations();
        }
        public void GetDeminifiedMethodNameFromSourceMap_MatchingMappingMultipleBindingsMissingPrototypeMapping_ReturnsMethodName()
        {
            // Arrange
            FunctionMapEntry functionMapEntry = new FunctionMapEntry
            {
                Bindings =
                    new List <BindingInformation>
                {
                    new BindingInformation
                    {
                        SourcePosition = new SourcePosition {
                            ZeroBasedLineNumber = 86, ZeroBasedColumnNumber = 52
                        }
                    },
                    new BindingInformation
                    {
                        SourcePosition = new SourcePosition {
                            ZeroBasedLineNumber = 88, ZeroBasedColumnNumber = 78
                        }
                    }
                }
            };

            SourceMap sourceMap = MockRepository.GenerateStub <SourceMap>();

            sourceMap.Stub(
                x =>
                x.GetMappingEntryForGeneratedSourcePosition(
                    Arg <SourcePosition> .Matches(y => y.ZeroBasedLineNumber == 86 && y.ZeroBasedColumnNumber == 52)))
            .Return(null);

            sourceMap.Stub(
                x =>
                x.GetMappingEntryForGeneratedSourcePosition(
                    Arg <SourcePosition> .Matches(y => y.ZeroBasedLineNumber == 88 && y.ZeroBasedColumnNumber == 78)))
            .Return(new MappingEntry
            {
                OriginalName = "baz",
            });

            // Act
            string result = FunctionMapGenerator.GetDeminifiedMethodNameFromSourceMap(functionMapEntry, sourceMap);

            // Assert
            Assert.Equal("baz", result);
            sourceMap.VerifyAllExpectations();
        }