public void FortifyFprConverter_GetFailureLevelFromRuleMetadata_ReturnsAppropriateFailureLevel() { var expectedInputOutputs = new Dictionary <string, FailureLevel> { { "0.0", FailureLevel.Note }, { "0.5", FailureLevel.Note }, { "1.0", FailureLevel.Note }, { "1.1", FailureLevel.Warning }, { "2.0", FailureLevel.Warning }, { "2.5", FailureLevel.Warning }, { "2.9", FailureLevel.Warning }, { "3.0", FailureLevel.Warning }, { "3.1", FailureLevel.Error }, { "3.5", FailureLevel.Error }, { "3.9", FailureLevel.Error }, { "4.5", FailureLevel.Error }, { "5.0", FailureLevel.Error }, { "-5.5", FailureLevel.Warning }, //Invalid value, we default it to Warning { "5.5", FailureLevel.Error }, // Invalid value, we guess that it should be treated as Error }; foreach (KeyValuePair <string, FailureLevel> keyValuePair in expectedInputOutputs) { ReportingDescriptor rule = new ReportingDescriptor(); rule.SetProperty <string>("Impact", keyValuePair.Key); FailureLevel level = FortifyFprConverter.GetFailureLevelFromRuleMetadata(rule); level.Should().Be(keyValuePair.Value); } }
public void FortifyFprConverter_GetFailureLevelFromRuleMetadata_MissingImpactProperty_ReturnsWarning() { ReportingDescriptor rule = new ReportingDescriptor(); FailureLevel level = FortifyFprConverter.GetFailureLevelFromRuleMetadata(rule); level.Should().Be(FailureLevel.Warning); }