Skip to content

Commit

Permalink
Added a unit test (#22361)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubaflo committed May 13, 2024
1 parent 7e458ea commit 9ef15d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Controls/src/Core/IndicatorView/IndicatorView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static void UpdateIndicatorLayout(IndicatorView indicatorView, object newValue)
{
indicatorView.IndicatorLayout = new IndicatorStackLayout(indicatorView) { Spacing = DefaultPadding };
}
else if (indicatorView.IndicatorLayout != null)
else if (indicatorView.IndicatorLayout is not null)
{
(indicatorView.IndicatorLayout as IndicatorStackLayout)?.Remove();
indicatorView.IndicatorLayout = null;
Expand Down
15 changes: 15 additions & 0 deletions src/Controls/tests/Core.UnitTests/IndicatorViewLayoutTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,20 @@ public void IndicatorStackLayout_ResetIndicatorCount_ShouldBindChildren(int oldC
// Assert
Assert.Equal(expected, indicatorStackLayout.Children.Count);
}

[Fact]
public void IndicatorLayout_ShouldBeRemovedWhenIndicatorVTemplateIsNulled()
{
// Arrange
var indicatorView = new IndicatorView() { ItemsSource = new List<string> { "item1", "item2" } };
indicatorView.IndicatorTemplate = new DataTemplate();
Assert.NotNull(indicatorView.IndicatorLayout);

// Act
indicatorView.IndicatorTemplate = null;

//Assert
Assert.Null(indicatorView.IndicatorLayout);
}
}
}

0 comments on commit 9ef15d1

Please sign in to comment.