-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IndicatorView IndicatorTemplate Binding (#19004)
* IndicatorView IndicatorTemplate Binding * Update to use BindableLayout * Rename method * Add tests, replaced event with command * Update IndicatorStackLayout.cs * Fix compilation issue --------- Co-authored-by: Rui Marinho <[email protected]>
- Loading branch information
1 parent
7c7f512
commit 6f5ca12
Showing
3 changed files
with
108 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/Controls/tests/Core.UnitTests/IndicatorViewLayoutTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace Microsoft.Maui.Controls.Core.UnitTests | ||
{ | ||
public class IndicatorViewTests : BaseTestFixture | ||
{ | ||
[Fact] | ||
public void IndicatorStackLayoutNoItems_ResetIndicators_ShouldHaveNoChildren() | ||
{ | ||
// Arrange | ||
var indicatorView = new IndicatorView(); | ||
var indicatorStackLayout = new IndicatorStackLayout(indicatorView); | ||
|
||
// Act | ||
indicatorStackLayout.ResetIndicators(); | ||
|
||
// Assert | ||
Assert.Empty(indicatorStackLayout.Children); | ||
} | ||
|
||
[Fact] | ||
public void IndicatorStackLayoutWithItems_ResetIndicators_ShouldBindChildren() | ||
{ | ||
// Arrange | ||
var indicatorView = new IndicatorView() { ItemsSource = new List<string>{"item1", "item2"} }; | ||
var indicatorStackLayout = new IndicatorStackLayout(indicatorView); | ||
|
||
// Act | ||
indicatorStackLayout.ResetIndicators(); | ||
|
||
// Assert | ||
Assert.Equal(2, indicatorStackLayout.Children.Count); | ||
} | ||
|
||
[Theory] | ||
[InlineData(1, 2)] | ||
[InlineData(0, 2)] | ||
[InlineData(-2, 2)] | ||
public void IndicatorStackLayout_ResetIndicatorCount_ShouldBindChildren(int oldCount, int expected) | ||
{ | ||
// Arrange | ||
var indicatorView = new IndicatorView() { ItemsSource = new List<string>{"item1", "item2"} }; | ||
var indicatorStackLayout = new IndicatorStackLayout(indicatorView); | ||
Assert.Empty(indicatorStackLayout.Children); | ||
|
||
// Act | ||
indicatorStackLayout.ResetIndicatorCount(oldCount); | ||
|
||
// Assert | ||
Assert.Equal(expected, indicatorStackLayout.Children.Count); | ||
} | ||
} | ||
} |