Color Picker: Validate uniqueness of selected colors (#20431)
* Added unique color checker to color picker. * Added Unittest for duplicates * optimized for codescene * removed the bump and simplified the function * Fixed behaviour for duplicate checks so unit test passes. A little refactoring. * Adds continue so invalid colors aren't checked for duplicates. --------- Co-authored-by: Andy Butland <abutland73@gmail.com>
This commit is contained in:
@@ -58,4 +58,24 @@ public class ColorListValidatorTest
|
||||
PropertyValidationContext.Empty());
|
||||
Assert.AreEqual(2, result.Count());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Validates_Color_Vals_Are_Unique()
|
||||
{
|
||||
var validator = new ColorPickerConfigurationEditor.ColorListValidator(ConfigurationEditorJsonSerializer());
|
||||
var result =
|
||||
validator.Validate(
|
||||
new JsonArray(
|
||||
JsonNode.Parse("""{"value": "FFFFFF", "label": "One"}"""),
|
||||
JsonNode.Parse("""{"value": "000000", "label": "Two"}"""),
|
||||
JsonNode.Parse("""{"value": "FF00AA", "label": "Three"}"""),
|
||||
JsonNode.Parse("""{"value": "fff", "label": "Four"}"""),
|
||||
JsonNode.Parse("""{"value": "000000", "label": "Five"}"""),
|
||||
JsonNode.Parse("""{"value": "F0A", "label": "Six"}""")),
|
||||
null,
|
||||
null,
|
||||
PropertyValidationContext.Empty());
|
||||
Assert.AreEqual(1, result.Count());
|
||||
Assert.IsTrue(result.First().ErrorMessage.Contains("ffffff, 000000, ff00aa"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user