|
| 1 | +// Licensed to the .NET Foundation under one or more agreements. |
| 2 | +// The .NET Foundation licenses this file to you under the MIT license. |
| 3 | + |
| 4 | +namespace System.Windows.Forms.PropertyGridInternal.Tests; |
| 5 | + |
| 6 | +public class ArrayElementGridEntryTests |
| 7 | +{ |
| 8 | + private class TestGridEntry : GridEntry |
| 9 | + { |
| 10 | + public TestGridEntry(PropertyGrid ownerGrid, GridEntry? parent = null) |
| 11 | + : base(ownerGrid, parent) |
| 12 | + { |
| 13 | + PropertyValue = new int[] { 1, 2, 3 }; |
| 14 | + } |
| 15 | + |
| 16 | + public override GridItemType GridItemType => GridItemType.Property; |
| 17 | + public override bool IsValueEditable => true; |
| 18 | + public override string PropertyLabel => "Test"; |
| 19 | + public override Type? PropertyType => typeof(int[]); |
| 20 | + public override object? PropertyValue { get; set; } |
| 21 | + public override bool ShouldRenderReadOnly => false; |
| 22 | + } |
| 23 | + |
| 24 | + private static PropertyGrid CreatePropertyGrid() => new(); |
| 25 | + |
| 26 | + [WinFormsFact] |
| 27 | + public void ArrayElementGridEntry_ConstructorAndProperties() |
| 28 | + { |
| 29 | + using PropertyGrid grid = CreatePropertyGrid(); |
| 30 | + TestGridEntry parent = new(grid); |
| 31 | + ArrayElementGridEntry entry = new(grid, parent, 2); |
| 32 | + |
| 33 | + entry.Should().NotBeNull(); |
| 34 | + entry.PropertyLabel.Should().Be("[2]"); |
| 35 | + entry.GridItemType.Should().Be(GridItemType.ArrayValue); |
| 36 | + entry.IsValueEditable.Should().BeTrue(); |
| 37 | + entry.PropertyType.Should().Be(typeof(int)); |
| 38 | + entry.ShouldRenderReadOnly.Should().BeFalse(); |
| 39 | + entry.PropertyValue.Should().Be(3); |
| 40 | + |
| 41 | + entry.PropertyValue = 10; |
| 42 | + entry.PropertyValue.Should().Be(10); |
| 43 | + } |
| 44 | +} |
0 commit comments