static void TestParseEditorConfigCodeStyleOption(string args, bool isEnabled, DiagnosticSeverity severity)
        {
            var notificationOption = NotificationOption.None;

            switch (severity)
            {
            case DiagnosticSeverity.Hidden:
                notificationOption = NotificationOption.None;
                break;

            case DiagnosticSeverity.Info:
                notificationOption = NotificationOption.Suggestion;
                break;

            case DiagnosticSeverity.Warning:
                notificationOption = NotificationOption.Warning;
                break;

            case DiagnosticSeverity.Error:
                notificationOption = NotificationOption.Error;
                break;
            }

            var codeStyleOption = new CodeStyleOption <bool>(value: isEnabled, notification: notificationOption);

            CodeStyleHelpers.TryParseBoolEditorConfigCodeStyleOption(args, out var result);
            Assert.True(result.Value == isEnabled,
                        $"Expected {nameof(isEnabled)} to be {isEnabled}, was {result.Value}");
            Assert.True(result.Notification.Value == severity,
                        $"Expected {nameof(severity)} to be {severity}, was {result.Notification.Value}");
        }
Example #2
0
        public void TestParseEditorConfigCodeStyleOption(string args, bool isEnabled, ReportDiagnostic severity)
        {
            var notificationOption = NotificationOption.Silent;

            switch (severity)
            {
            case ReportDiagnostic.Hidden:
                notificationOption = NotificationOption.Silent;
                break;

            case ReportDiagnostic.Info:
                notificationOption = NotificationOption.Suggestion;
                break;

            case ReportDiagnostic.Warn:
                notificationOption = NotificationOption.Warning;
                break;

            case ReportDiagnostic.Error:
                notificationOption = NotificationOption.Error;
                break;
            }

            CodeStyleHelpers.TryParseBoolEditorConfigCodeStyleOption(args, out var result);
            Assert.True(result.Value == isEnabled,
                        $"Expected {nameof(isEnabled)} to be {isEnabled}, was {result.Value}");
            Assert.True(result.Notification.Severity == severity,
                        $"Expected {nameof(severity)} to be {severity}, was {result.Notification.Severity}");
        }
Example #3
0
 public void TestParseEditorConfigCodeStyleOption(string args, bool isEnabled, ReportDiagnostic severity)
 {
     CodeStyleHelpers.TryParseBoolEditorConfigCodeStyleOption(args, out var result);
     Assert.True(result.Value == isEnabled,
                 $"Expected {nameof(isEnabled)} to be {isEnabled}, was {result.Value}");
     Assert.True(result.Notification.Severity == severity,
                 $"Expected {nameof(severity)} to be {severity}, was {result.Notification.Severity}");
 }
Example #4
0
 private static Optional <CodeStyleOption <bool> > ParseBoolCodeStyleOption(string str)
 => CodeStyleHelpers.TryParseBoolEditorConfigCodeStyleOption(str, out var result) ? result : new Optional <CodeStyleOption <bool> >();