示例#1
0
        public void BuildMap_DuplicateSolutionFolderNamesAreIgnored()
        {
            // See #413: https://github.com/SonarSource/sonarlint-visualstudio/issues/413

            // Arrange
            var vsSolutionMock = SetupSolutionMocks(
                new KeyValuePair <string, string>("SolutionFolder1", "11111111-1111-1111-1111-111111111111"),
                new KeyValuePair <string, string>("Item1", "22222222-2222-2222-2222-222222222222"),
                new KeyValuePair <string, string>("SolutionFolder2", "33333333-3333-3333-3333-333333333333"),
                new KeyValuePair <string, string>("Item1", "44444444-4444-4444-4444-444444444444"),
                new KeyValuePair <string, string>("realProject.csproj", "55555555-5555-5555-5555-555555555555"),
                new KeyValuePair <string, string>("item1", "66666666-6666-6666-6666-666666666666"),
                new KeyValuePair <string, string>("ITEM1", "77777777-7777-7777-7777-777777777777")
                );

            uint fileCountOut;

            // Act
            IDictionary <string, string> map = LiveIssueFactory.BuildProjectPathToIdMap(vsSolutionMock.Object);

            // Assert
            vsSolutionMock.Verify(x => x.GetProjectFilesInSolution(0, It.IsAny <uint>(), It.IsAny <string[]>(), out fileCountOut),
                                  Times.Exactly(2));
            vsSolutionMock.As <IVsSolution5>().Verify(x => x.GetGuidOfProjectFile(It.IsAny <string>()), Times.Exactly(7));

            // Duplicate entries should have been ignored
            map.ContainsKey("SolutionFolder1").Should().BeTrue();
            map.ContainsKey("Item1").Should().BeTrue();
            map.ContainsKey("SolutionFolder2").Should().BeTrue();
            map.ContainsKey("realProject.csproj").Should().BeTrue();
            map.Count.Should().Be(4);

            map["SolutionFolder1"].Should().Be("11111111-1111-1111-1111-111111111111");
            map["SolutionFolder2"].Should().Be("33333333-3333-3333-3333-333333333333");
            map["realProject.csproj"].Should().Be("55555555-5555-5555-5555-555555555555");
            map["item1"].Should().Be("77777777-7777-7777-7777-777777777777");
        }