Ejemplo n.º 1
0
        public void GetErrorCode_SingleCppIssue_ErrorCodeReturned()
        {
            // Arrange
            var issueHandle = CreateIssueHandle(111, new Dictionary <string, object>
            {
                { StandardTableKeyNames.BuildTool, "SonarLint" },
                { StandardTableKeyNames.ErrorCode, "cpp:S123" }
            });
            var mockErrorList = CreateErrorList(issueHandle);

            // Act
            bool result = DisableRuleCommand.TryGetErrorCodeSync(mockErrorList, out var errorCode);

            // Assert
            result.Should().BeTrue();
            errorCode.Should().Be("cpp:S123");
        }
Ejemplo n.º 2
0
        public void GetErrorCode_NotSonarLintIssue()
        {
            // Arrange
            var issueHandle = CreateIssueHandle(111, new Dictionary <string, object>
            {
                { StandardTableKeyNames.BuildTool, new object() },
                { StandardTableKeyNames.ErrorCode, "cpp:S333" }
            });

            var mockErrorList = CreateErrorList(issueHandle);

            // Act
            bool result = DisableRuleCommand.TryGetErrorCodeSync(mockErrorList, out var errorCode);

            // Assert
            result.Should().BeFalse();
            errorCode.Should().BeNull();
        }
Ejemplo n.º 3
0
        public void GetErrorCode_NonStandardErrorCode_NoException_ErrorCodeNotReturned()
        {
            // Arrange
            var issueHandle = CreateIssueHandle(111, new Dictionary <string, object>
            {
                { StandardTableKeyNames.BuildTool, "SonarLint" },
                { StandardTableKeyNames.ErrorCode, ":" } // should not happen
            });

            var mockErrorList = CreateErrorList(issueHandle);

            // Act
            bool result = DisableRuleCommand.TryGetErrorCodeSync(mockErrorList, out var errorCode);

            // Assert
            result.Should().BeFalse();
            errorCode.Should().BeNull();
        }
Ejemplo n.º 4
0
        public void GetErrorCode_MultipleItemsSelected_ErrorCodeNotReturned()
        {
            var cppIssueHandle = CreateIssueHandle(111, new Dictionary <string, object>
            {
                { StandardTableKeyNames.BuildTool, "SonarLint" },
                { StandardTableKeyNames.ErrorCode, "cpp:S222" }
            });
            var jsIssueHandle = CreateIssueHandle(222, new Dictionary <string, object>
            {
                { StandardTableKeyNames.BuildTool, "SonarLint" },
                { StandardTableKeyNames.ErrorCode, "javascript:S222" }
            });

            var mockErrorList = CreateErrorList(cppIssueHandle, jsIssueHandle);

            // Act
            bool result = DisableRuleCommand.TryGetErrorCodeSync(mockErrorList, out var errorCode);

            // Assert
            result.Should().BeFalse();
            errorCode.Should().BeNull();
        }