Beispiel #1
0
        public void GetDeminifiedMethodNameFromSourceMap_HasSingleBindingMatchingMapping_ReturnsMethodName()
        {
            // Arrange
            FunctionMapEntry functionMapEntry = new FunctionMapEntry
            {
                Bindings =
                    new List <BindingInformation>
                {
                    new BindingInformation
                    {
                        SourcePosition = new SourcePosition {
                            ZeroBasedLineNumber = 5, ZeroBasedColumnNumber = 8
                        }
                    }
                }
            };

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

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

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

            // Assert
            Assert.AreEqual("foo", result);
            sourceMap.VerifyAllExpectations();
        }
Beispiel #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();
        }
Beispiel #3
0
        public void GetDeminifiedMethodNameFromSourceMap_NoBinding_ReturnNullMethodName()
        {
            // Arrange
            FunctionMapEntry functionMapEntry = new FunctionMapEntry();
            SourceMap        sourceMap        = MockRepository.GenerateStub <SourceMap>();

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

            // Assert
            Assert.IsNull(result);
            sourceMap.VerifyAllExpectations();
        }
Beispiel #4
0
        public void GetDeminifiedMethodName_EmptyBinding_ReturnNullMethodName()
        {
            // Arrange
            IReadOnlyList <BindingInformation> bindings = new List <BindingInformation>();
            SourceMap sourceMap = CreateSourceMapMock();

            // Act
            string result = SourceMapExtensions.GetDeminifiedMethodName(sourceMap, bindings);

            // Assert
            Assert.Null(result);
            sourceMap.VerifyAllExpectations();
        }