diff --git a/.globalconfig b/.globalconfig index 224b24785514..31939ab4f57f 100644 --- a/.globalconfig +++ b/.globalconfig @@ -171,7 +171,7 @@ dotnet_diagnostic.MSTEST0023.severity = warning dotnet_diagnostic.MSTEST0025.severity = warning # MSTEST0026: Avoid conditional access in assertions -dotnet_diagnostic.MSTEST0026.severity = warning +dotnet_diagnostic.MSTEST0026.severity = suggestion # MSTEST0029: Public method should be test method dotnet_diagnostic.MSTEST0029.severity = warning diff --git a/src/SamplesApp/UITests.Shared/Windows_Storage/NativeStorageRuntimeTests.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_Storage/NativeStorageRuntimeTests.xaml.cs index b147d3985928..b5befcd00a19 100644 --- a/src/SamplesApp/UITests.Shared/Windows_Storage/NativeStorageRuntimeTests.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_Storage/NativeStorageRuntimeTests.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.ObjectModel; using System.Linq; using System.Threading; @@ -13,6 +13,7 @@ using Windows.UI.Core; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Microsoft.VisualStudio.TestTools.UnitTesting; namespace UITests.Windows_Storage { @@ -96,6 +97,7 @@ private async void RunFileIOTests() } } +#pragma warning disable MSTEST0030 // Type containing [TestMethod] should be marked with [TestClass] - instantiated explicitly. public class Pickable_StorageFolder_Tests : Given_StorageFolder_Native_Base { private readonly StorageFolder _rootFolder; @@ -131,4 +133,5 @@ public Pickable_FileIO_Tests(StorageFolder rootFolder) protected override Task GetRootFolderAsync() => Task.FromResult(_rootFolder); } +#pragma warning restore MSTEST0030 } diff --git a/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/grid/GridIntegrationTests.cs b/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/grid/GridIntegrationTests.cs index 9dd5e0d149a3..c89c1a1bc389 100644 --- a/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/grid/GridIntegrationTests.cs +++ b/src/Uno.UI.RuntimeTests/IntegrationTests/dxaml/controls/grid/GridIntegrationTests.cs @@ -561,8 +561,9 @@ await TestServices.RunOnUIThread(() => }); } -#if !__ANDROID__ && !__IOS__ [TestMethod] +#if __ANDROID__ || __IOS__ + [Ignore] #endif public async Task CanZeroWeightedCellsShrinkToZeroSize() { diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/FlowLayoutCollectionChangeTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/FlowLayoutCollectionChangeTests.cs index 82e9fafa36df..17b7fd06856e 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/FlowLayoutCollectionChangeTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/FlowLayoutCollectionChangeTests.cs @@ -472,7 +472,8 @@ public async Task EnsureReplaceOfAnchorDoesNotResetAllContainers() }); } - //[TestMethod] + [TestMethod] + [Ignore] public void ReplaceMultipleItems() { // TODO: Lower prioirty scenario. Tracked by work item: 9738020 diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/InspectingDataSourceTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/InspectingDataSourceTests.cs index 8fb7a53ab5be..2b3f0118ea89 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/InspectingDataSourceTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/InspectingDataSourceTests.cs @@ -273,7 +273,7 @@ void ItemsSourceView_CollectionChanged(object sender, NotifyCollectionChangedEve } //TODO Uno specific: This test is adjusted to pass on Android - UpdateLayout needs to be called twice. - public async Task ValidateSwitchingItemsSourceRefreshesElements(bool isVirtualLayout) + private async Task ValidateSwitchingItemsSourceRefreshesElements(bool isVirtualLayout) { const int numItems = 10; ItemsRepeater repeater = null; diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ItemTemplateTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ItemTemplateTests.cs index 24f3f5671184..fa1aeede0a9d 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ItemTemplateTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ItemTemplateTests.cs @@ -542,7 +542,7 @@ await RunOnUIThread.ExecuteAsync(async () => }); } - public async Task ValidateTemplateSwitchingRefreshesElements(Layout layout) + private async Task ValidateTemplateSwitchingRefreshesElements(Layout layout) { var dataTemplate1 = (DataTemplate)XamlReader.Load( @" diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/RecyclePoolTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/RecyclePoolTests.cs index bc7328130818..83f850e11c31 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/RecyclePoolTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/RecyclePoolTests.cs @@ -32,7 +32,8 @@ namespace Microsoft.UI.Xaml.Tests.MUXControls.ApiTests.RepeaterTests [TestClass] public class RecyclePoolTests : MUXApiTestBase { - + [Ignore("https://github.com/unoplatform/uno/issues/9080")] + [TestMethod] public void ValidateElementsHaveCorrectKeys() { RunOnUIThread.Execute(() => diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ViewManagerTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ViewManagerTests.cs index 4854a3d13c05..9693bd3b179f 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ViewManagerTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ViewManagerTests.cs @@ -90,7 +90,8 @@ public void CanQueryElementFactory() }); } - // [TestMethod] Issue #1018 + [TestMethod] // Issue #1018 + [Ignore] public async Task CanPinFocusedElements() { // Setup a grouped repeater scenario with two groups each containing two items. @@ -191,7 +192,8 @@ public async Task CanPinFocusedElements() }); } - // [TestMethod] Issue 1018 + [TestMethod] // Issue 1018 + [Ignore] public async Task CanReuseElementsDuringUniqueIdReset() { var data = new WinRTCollection(Enumerable.Range(0, 2).Select(i => string.Format("Item #{0}", i))); @@ -678,7 +680,8 @@ public void ValidateDataContextGetsPropagated() }); } - // [TestMethod] Issue 1018 + [TestMethod] // Issue 1018 + [Ignore] public async Task ValidateFocusMoveOnElementCleared() { CustomItemsSource dataSource = null; @@ -721,7 +724,8 @@ await SharedHelpers.RunActionsWithWait( }); } - // [TestMethod] Issue 1018 + [TestMethod] // Issue 1018 + [Ignore] public async Task ValidateFocusMoveOnElementClearedWithUniqueIds() { CustomItemsSource dataSource = null; diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ViewportTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ViewportTests.cs index a847f6294172..7ec552e65c6d 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ViewportTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/Repeater/ViewportTests.cs @@ -109,7 +109,8 @@ public void ValidateNoScrollingSurfaceScenario() }); } - // [TestMethod] Temporarily disabled for bug 18866003 + [TestMethod] // Temporarily disabled for bug 18866003 + [Ignore] public async Task ValidateItemsRepeaterScrollHostScenario() { var realizationRects = new List(); @@ -854,7 +855,8 @@ public void ValidateSuggestedElement() }); } - // [TestMethod] Temporarily disabled for bug 18866003 + [TestMethod] // Temporarily disabled for bug 18866003 + [Ignore] public async Task ValidateLoadUnload() { if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone2)) diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TimePicker/TimePickerIntegrationTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TimePicker/TimePickerIntegrationTests.cs index 2c2b3f0248b3..6c5085c92055 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TimePicker/TimePickerIntegrationTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TimePicker/TimePickerIntegrationTests.cs @@ -88,7 +88,7 @@ await TestServices.RunOnUIThread(() => { var timePickerFlyoutPresenter = TreeHelper.GetVisualChildByTypeFromOpenPopups(timePicker); Assert.IsNotNull(timePickerFlyoutPresenter); - Assert.AreEqual(true, timePickerFlyoutPresenter.IsDefaultShadowEnabled); + Assert.IsTrue(timePickerFlyoutPresenter.IsDefaultShadowEnabled); }); #endif } diff --git a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TreeView/TreeViewTests.cs b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TreeView/TreeViewTests.cs index 088725b32eb3..b88e91f2f863 100644 --- a/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TreeView/TreeViewTests.cs +++ b/src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TreeView/TreeViewTests.cs @@ -262,7 +262,8 @@ await RunOnUIThread.ExecuteAsync(() => await TestServices.WindowHelper.WaitForIdle(); } - //[TestMethod] Disabled with issue number #1775 (WinUI issue) + [TestMethod] // Disabled with issue number #1775 (WinUI issue) + [Ignore] public void TreeViewInheritanceTest() { StackPanel stackPanel = new StackPanel(); diff --git a/src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_NavigationView.cs b/src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_NavigationView.cs index 1cda645c309a..bddd2428a1ef 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_NavigationView.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_NavigationView.cs @@ -68,7 +68,7 @@ public async Task When_SelectedItem_Set_Before_Load_And_Theme_Changed() #if __ANDROID__ // This is the meat of the test - we verify that the actual color of the TextBlock matches the managed Color, which will only be the // case if it was correctly measured and arranged as requested after the theme changed. - Assert.AreEqual(false, iconTextBlock.IsLayoutRequested); + Assert.IsFalse(iconTextBlock.IsLayoutRequested); Assert.AreEqual((Android.Graphics.Color)((iconTextBlock.Foreground as SolidColorBrush).Color), iconTextBlock.NativeArrangedColor); #endif } diff --git a/src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_TreeView.cs b/src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_TreeView.cs index 3b07fabbe7d5..25780da4b7b1 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_TreeView.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_TreeView.cs @@ -101,11 +101,11 @@ public async Task When_TreeViewItem_Dragged_Near_the_Edge() mouse.MoveBy(0, 1); await WindowHelper.WaitForIdle(); - Assert.AreEqual(dragStartingCount, 0); + Assert.AreEqual(0, dragStartingCount); mouse.MoveBy(0, 15); // move out of the tvi await WindowHelper.WaitForIdle(); - Assert.AreEqual(dragStartingCount, 1); + Assert.AreEqual(1, dragStartingCount); } #endif @@ -703,8 +703,8 @@ public async Task When_SelectedItem_NotExpandedToExpanded() // assert: before expanding Assert.AreEqual(targetItem, tvm.SelectedItem, "[collapsed]invalid tvm.SelectedItem"); Assert.AreEqual(targetItem, SUT.SelectedItem, "[collapsed]invalid SUT.SelectedItem"); - Assert.AreEqual(null, SUT.SelectedNode, "[collapsed]invalid SUT.SelectedNode should be null"); - Assert.AreEqual(null, SUT.NodeFromContainer(SUT.ContainerFromItem(targetItem)), "[collapsed]selected node should not exist yet"); + Assert.IsNull(SUT.SelectedNode, "[collapsed]invalid SUT.SelectedNode should be null"); + Assert.IsNull(SUT.NodeFromContainer(SUT.ContainerFromItem(targetItem)), "[collapsed]selected node should not exist yet"); // expand the ancestry from top-down for (int i = 1; i < targetItem.Label.Length; i++) @@ -768,10 +768,10 @@ public async Task When_IsSelectedItem_NotExpandedToExpanded() await UITestHelper.Load(setup); // assert: before expanding - Assert.AreEqual(null, tvm.SelectedItem, "[collapsed]invalid tvm.SelectedItem"); - Assert.AreEqual(null, SUT.SelectedItem, "[collapsed]invalid SUT.SelectedItem"); - Assert.AreEqual(null, SUT.SelectedNode, "[collapsed]invalid SUT.SelectedNode should be null"); - Assert.AreEqual(null, SUT.NodeFromContainer(SUT.ContainerFromItem(targetItem)), "[collapsed]selected node should not exist yet"); + Assert.IsNull(tvm.SelectedItem, "[collapsed]invalid tvm.SelectedItem"); + Assert.IsNull(SUT.SelectedItem, "[collapsed]invalid SUT.SelectedItem"); + Assert.IsNull(SUT.SelectedNode, "[collapsed]invalid SUT.SelectedNode should be null"); + Assert.IsNull(SUT.NodeFromContainer(SUT.ContainerFromItem(targetItem)), "[collapsed]selected node should not exist yet"); // expand the ancestry from top-down for (int i = 1; i < targetItem.Label.Length; i++) diff --git a/src/Uno.UI.RuntimeTests/Tests/TemplatedParent/TemplatedParentTests.cs b/src/Uno.UI.RuntimeTests/Tests/TemplatedParent/TemplatedParentTests.cs index 4519d56e698e..7679941074a2 100644 --- a/src/Uno.UI.RuntimeTests/Tests/TemplatedParent/TemplatedParentTests.cs +++ b/src/Uno.UI.RuntimeTests/Tests/TemplatedParent/TemplatedParentTests.cs @@ -218,7 +218,7 @@ public async Task ItemsControl_HeaderFooter_NoTP_DynamicXaml() await ItemsControl_HeaderFooter_NoTP(sut, sut); } - public async Task ItemsControl_HeaderFooter_NoTP(FrameworkElement setup, ItemsControl sut) + private async Task ItemsControl_HeaderFooter_NoTP(FrameworkElement setup, ItemsControl sut) { await UITestHelper.Load(setup, x => x.IsLoaded); diff --git a/src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Method.cs b/src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Method.cs index f42315f77075..91e1d0870eff 100644 --- a/src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Method.cs +++ b/src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Method.cs @@ -25,7 +25,9 @@ public static IEnumerable GetData() yield return new object[] { 14, 1, 15 }; } +#pragma warning disable MSTEST0029 // Public methods should be test methods - https://github.com/microsoft/testfx/issues/4660 public void Dispose() => Assert.Equals(TestSucces_Count, 3); +#pragma warning restore MSTEST0029 // Public methods should be test methods } } diff --git a/src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Property.cs b/src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Property.cs index 0c36a7658da3..3190fe557f83 100644 --- a/src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Property.cs +++ b/src/Uno.UI.RuntimeTests/Tests/UnitTestsTests/Give_UnitTest_DynamicData_From_Property.cs @@ -28,7 +28,9 @@ public static IEnumerable Data } } +#pragma warning disable MSTEST0029 // Public methods should be test methods - https://github.com/microsoft/testfx/issues/4660 public void Dispose() => Assert.Equals(TestSucces_Count, 3); +#pragma warning restore MSTEST0029 // Public methods should be test methods } } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_System/Given_DispatcherQueueTimer.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_System/Given_DispatcherQueueTimer.cs index b4c244e8ee6a..8966fe6577b1 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_System/Given_DispatcherQueueTimer.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_System/Given_DispatcherQueueTimer.cs @@ -65,7 +65,7 @@ public async Task When_ScheduleRepeatingWorkItem() await Task.WhenAny(tcs.Task, Task.Delay(30000)); Assert.IsTrue(tcs.Task.IsCompleted); - Assert.AreEqual(count, 3); + Assert.AreEqual(3, count); } finally { diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_System_Threading/Given_ThreadPoolTimer.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_System_Threading/Given_ThreadPoolTimer.cs index fad76e8e3c36..0c9b29adf476 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_System_Threading/Given_ThreadPoolTimer.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_System_Threading/Given_ThreadPoolTimer.cs @@ -19,11 +19,11 @@ public async Task When_Timer() await Task.Delay(500); - Assert.AreEqual(handlerCount, 1); + Assert.AreEqual(1, handlerCount); await Task.Delay(500); - Assert.AreEqual(handlerCount, 1); + Assert.AreEqual(1, handlerCount); } [TestMethod] diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_StartScreen/Given_JumpListItem.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_StartScreen/Given_JumpListItem.cs index c87f85ddcfc2..0755b1ffb695 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_StartScreen/Given_JumpListItem.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_StartScreen/Given_JumpListItem.cs @@ -67,8 +67,8 @@ public void When_Instance_Is_Created_Default_Values() { var item = JumpListItem.CreateWithArguments("Hello", "test"); Assert.AreEqual(string.Empty, item.Description); - Assert.AreEqual(null, item.Logo); - Assert.AreEqual(false, item.RemovedByUser); + Assert.IsNull(item.Logo); + Assert.IsFalse(item.RemovedByUser); Assert.AreEqual(JumpListItemKind.Arguments, item.Kind); } @@ -93,7 +93,7 @@ public void When_Logo_Uri_Is_Set_To_Null() { var item = JumpListItem.CreateWithArguments("Hello", "Test"); item.Logo = null; - Assert.AreEqual(null, item.Logo); + Assert.IsNull(item.Logo); } [TestMethod] diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Control.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Control.cs index 5dea2dbc37e5..6dc810b6653e 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Control.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Control.cs @@ -244,7 +244,7 @@ public void When_Template_Changes_Should_Not_Be_Materialized_Immediately() Assert.AreEqual(0, ConstructorCounterControl.ConstructorCount); Assert.AreEqual(0, ConstructorCounterControl.ApplyTemplateCount); Assert.AreEqual(0, control.ApplyTemplateCount); - Assert.AreEqual(false, control.ApplyTemplate()); + Assert.IsFalse(control.ApplyTemplate()); Assert.AreEqual(0, ConstructorCounterControl.ConstructorCount); Assert.AreEqual(0, ConstructorCounterControl.ApplyTemplateCount); Assert.AreEqual(0, control.ApplyTemplateCount); @@ -254,7 +254,7 @@ public void When_Template_Changes_Should_Not_Be_Materialized_Immediately() Assert.AreEqual(0, ConstructorCounterControl.ConstructorCount); Assert.AreEqual(0, ConstructorCounterControl.ApplyTemplateCount); Assert.AreEqual(0, control.ApplyTemplateCount); - Assert.AreEqual(true, control.ApplyTemplate()); + Assert.IsTrue(control.ApplyTemplate()); Assert.AreEqual(1, ConstructorCounterControl.ConstructorCount); Assert.AreEqual(0, ConstructorCounterControl.ApplyTemplateCount); Assert.AreEqual(1, control.ApplyTemplateCount); @@ -286,7 +286,7 @@ public void When_Measure_Should_Materialize_Template() Assert.AreEqual(1, ConstructorCounterControl.ConstructorCount); Assert.AreEqual(0, ConstructorCounterControl.ApplyTemplateCount); Assert.AreEqual(1, control.ApplyTemplateCount); - Assert.AreEqual(false, control.ApplyTemplate()); + Assert.IsFalse(control.ApplyTemplate()); Assert.AreEqual(1, ConstructorCounterControl.ConstructorCount); Assert.AreEqual(0, ConstructorCounterControl.ApplyTemplateCount); Assert.AreEqual(1, control.ApplyTemplateCount); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_DispatcherTimer.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_DispatcherTimer.cs index 45e68bfa9007..36261bd1de29 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_DispatcherTimer.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_DispatcherTimer.cs @@ -126,7 +126,7 @@ void HandleException(object s, UnhandledExceptionEventArgs e) await TestServices.WindowHelper.WaitFor(() => tickCounter > 0); await Task.Delay(200); // Second tick never happens - Assert.AreEqual(tickCounter, 1); + Assert.AreEqual(1, tickCounter); // Even then, the timer still appears enabled Assert.IsTrue(dispatcherTimer.IsEnabled); } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Panel.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Panel.cs index 708ae003270f..35e72d889262 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Panel.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_Panel.cs @@ -63,8 +63,8 @@ public async Task When_Overriding_Measure_Arrange() Assert.IsTrue(Math.Abs(parent.ActualSize.Y - lv.ActualSize.Y) < 1); // MeasureOverride should be returning the default Size(0,0) - Assert.AreEqual(lv.DesiredSize.Width, 0); - Assert.AreEqual(lv.DesiredSize.Height, 0); + Assert.AreEqual(0, lv.DesiredSize.Width); + Assert.AreEqual(0, lv.DesiredSize.Height); for (var i = 0; i < 4; i++) { diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_ResourceDictionary.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_ResourceDictionary.cs index 5a38cbd3ca6f..2c04efb3c058 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_ResourceDictionary.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_ResourceDictionary.cs @@ -235,8 +235,8 @@ public void When_LinkedResDict_ThemeUpdated() var materialized4 = (SolidColorBrush)copy[TestBrush]; // validation - Assert.AreEqual(false, ReferenceEquals(materialized1, materialized2)); // we are expecting these to be different, as the CopyFrom should copy them as WeakResourceInitializer... - Assert.AreEqual(false, ReferenceEquals(materialized3, materialized4)); // ^same + Assert.IsFalse(ReferenceEquals(materialized1, materialized2)); // we are expecting these to be different, as the CopyFrom should copy them as WeakResourceInitializer... + Assert.IsFalse(ReferenceEquals(materialized3, materialized4)); // ^same Assert.AreNotEqual(materialized2Color, materialized4.Color); // check the theme change is actually applied (otherwise it would void the next check) Assert.AreEqual(materialized3.Color, materialized4.Color); // check the theme change is propagated to the source res-dict } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.TransformToVisual.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.TransformToVisual.cs index d966d9e18638..ff0207d00470 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.TransformToVisual.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml/Given_UIElement.TransformToVisual.cs @@ -126,29 +126,29 @@ void AssertItem(int index) ?? throw new NullReferenceException($"Cannot find the materialized border of item {index}"); var containerToListView = container.TransformToVisual(listView).TransformBounds(new Rect(0, 0, 42, 42)); - Assert.AreEqual(containerToListView.X, 0, tolerance); - Assert.AreEqual(containerToListView.X, 0, tolerance); + Assert.AreEqual(0, containerToListView.X, tolerance); + Assert.AreEqual(0, containerToListView.X, tolerance); Assert.AreEqual(containerToListView.Y, ((100 + 5 * 2) * index), tolerance); - Assert.AreEqual(containerToListView.Width, 42, tolerance); - Assert.AreEqual(containerToListView.Height, 42, tolerance); + Assert.AreEqual(42, containerToListView.Width, tolerance); + Assert.AreEqual(42, containerToListView.Height, tolerance); var borderToListView = border.TransformToVisual(listView).TransformBounds(new Rect(0, 0, 42, 42)); - Assert.AreEqual(borderToListView.X, 0, tolerance); + Assert.AreEqual(0, borderToListView.X, tolerance); Assert.AreEqual(borderToListView.Y, ((100 + 5 * 2) * index + 5), tolerance); - Assert.AreEqual(borderToListView.Width, 42, tolerance); - Assert.AreEqual(borderToListView.Height, 42, tolerance); + Assert.AreEqual(42, borderToListView.Width, tolerance); + Assert.AreEqual(42, borderToListView.Height, tolerance); var containerToSut = container.TransformToVisual(sut).TransformBounds(new Rect(0, 0, 42, 42)); - Assert.AreEqual(containerToSut.X, 15, tolerance); + Assert.AreEqual(15, containerToSut.X, tolerance); Assert.AreEqual(containerToSut.Y, (15 + (100 + 5 * 2) * index), tolerance); - Assert.AreEqual(containerToSut.Width, 42, tolerance); - Assert.AreEqual(containerToSut.Height, 42, tolerance); + Assert.AreEqual(42, containerToSut.Width, tolerance); + Assert.AreEqual(42, containerToSut.Height, tolerance); var borderToSut = border.TransformToVisual(sut).TransformBounds(new Rect(0, 0, 42, 42)); - Assert.AreEqual(borderToSut.X, 15, tolerance); + Assert.AreEqual(15, borderToSut.X, tolerance); Assert.AreEqual(borderToSut.Y, (15 + (100 + 5 * 2) * index + 5), tolerance); - Assert.AreEqual(borderToSut.Width, 42, tolerance); - Assert.AreEqual(borderToSut.Height, 42, tolerance); + Assert.AreEqual(42, borderToSut.Width, tolerance); + Assert.AreEqual(42, borderToSut.Height, tolerance); } } #endif diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/Given_AutomationPeer.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/Given_AutomationPeer.cs index a75f77ccafdb..f81f65c1e1ad 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/Given_AutomationPeer.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Automation/Given_AutomationPeer.cs @@ -21,7 +21,7 @@ public void When_AutomationPeer_Default_IsDialog() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsDialog(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -30,7 +30,7 @@ public void When_AutomationPeer_Default_GetPattern() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.GetPattern(PatternInterface.Drag); - Assert.AreEqual(null, result); + Assert.IsNull(result); } [TestMethod] @@ -84,7 +84,7 @@ public void When_AutomationPeer_Default_GetChildren() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.GetChildren(); - Assert.AreEqual(null, result); + Assert.IsNull(result); } [TestMethod] @@ -138,7 +138,7 @@ public void When_AutomationPeer_Default_GetLabeledBy() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.GetLabeledBy(); - Assert.AreEqual(null, result); + Assert.IsNull(result); } [TestMethod] @@ -174,7 +174,7 @@ public void When_AutomationPeer_Default_HasKeyboardFocus() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.HasKeyboardFocus(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -183,7 +183,7 @@ public void When_AutomationPeer_Default_IsContentElement() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsContentElement(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -192,7 +192,7 @@ public void When_AutomationPeer_Default_IsControlElement() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsControlElement(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -201,7 +201,7 @@ public void When_AutomationPeer_Default_IsEnabled() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsEnabled(); - Assert.AreEqual(true, result); + Assert.IsTrue(result); } [TestMethod] @@ -210,7 +210,7 @@ public void When_AutomationPeer_Default_IsKeyboardFocusable() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsKeyboardFocusable(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -219,7 +219,7 @@ public void When_AutomationPeer_Default_IsOffscreen() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsOffscreen(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -228,7 +228,7 @@ public void When_AutomationPeer_Default_IsPassword() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsPassword(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -237,7 +237,7 @@ public void When_AutomationPeer_Default_IsRequiredForForm() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsRequiredForForm(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -275,7 +275,7 @@ public void When_AutomationPeer_Default_Navigate() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.Navigate(default); - Assert.AreEqual(null, result); + Assert.IsNull(result); } [TestMethod] @@ -311,7 +311,7 @@ public void When_AutomationPeer_Default_GetControlledPeers() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.GetControlledPeers(); - Assert.AreEqual(null, result); + Assert.IsNull(result); } [TestMethod] @@ -320,7 +320,7 @@ public void When_AutomationPeer_Default_GetAnnotations() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.GetAnnotations(); - Assert.AreEqual(null, result); + Assert.IsNull(result); } [TestMethod] @@ -374,7 +374,7 @@ public void When_AutomationPeer_Default_IsPeripheral() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsPeripheral(); - Assert.AreEqual(false, result); + Assert.IsFalse(result); } [TestMethod] @@ -383,7 +383,7 @@ public void When_AutomationPeer_Default_IsDataValidForForm() { var automationPeer = new TestAutomationPeer(); var result = automationPeer.IsDataValidForForm(); - Assert.AreEqual(true, result); + Assert.IsTrue(result); } [TestMethod] diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/DatePickerIntegrationTests.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/DatePickerIntegrationTests.cs index d7d0db6e510e..3171f594a8ea 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/DatePickerIntegrationTests.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/DatePickerIntegrationTests.cs @@ -581,9 +581,9 @@ await RunOnUIThread.ExecuteAsync(() => await RunOnUIThread.ExecuteAsync(() => { - Assert.AreEqual(dayTextBlock.Text, expectedDayString); - Assert.AreEqual(monthTextBlock.Text, expectedMonthString); - Assert.AreEqual(yearTextBlock.Text, expectedYearString); + Assert.AreEqual(expectedDayString, dayTextBlock.Text); + Assert.AreEqual(expectedMonthString, monthTextBlock.Text); + Assert.AreEqual(expectedYearString, yearTextBlock.Text); }); // Verify that we can update the properties of DatePicker @@ -604,9 +604,9 @@ await RunOnUIThread.ExecuteAsync(() => await RunOnUIThread.ExecuteAsync(() => { - Assert.AreEqual(dayTextBlock.Text, expectedDayString); - Assert.AreEqual(monthTextBlock.Text, expectedMonthString); - Assert.AreEqual(yearTextBlock.Text, expectedYearString); + Assert.AreEqual(expectedDayString, dayTextBlock.Text); + Assert.AreEqual(expectedMonthString, monthTextBlock.Text); + Assert.AreEqual(expectedYearString, yearTextBlock.Text); }); } @@ -659,8 +659,8 @@ await RunOnUIThread.ExecuteAsync(() => await TestServices.WindowHelper.WaitForIdle(); await RunOnUIThread.ExecuteAsync(() => { - Assert.IsTrue(dayTextBlock.Visibility == Visibility.Collapsed); - Assert.IsFalse(flyoutButtonContentGrid.ColumnDefinitions.IndexOf(dayColumn) == 0); + Assert.AreEqual(Visibility.Collapsed, dayTextBlock.Visibility); + Assert.AreNotEqual(0, flyoutButtonContentGrid.ColumnDefinitions.IndexOf(dayColumn)); datePicker.DayVisible = true; datePicker.MonthVisible = false; @@ -668,11 +668,11 @@ await RunOnUIThread.ExecuteAsync(() => await TestServices.WindowHelper.WaitForIdle(); await RunOnUIThread.ExecuteAsync(() => { - Assert.IsTrue(dayTextBlock.Visibility == Visibility.Visible); - Assert.IsTrue(flyoutButtonContentGrid.ColumnDefinitions.IndexOf(dayColumn) == 0); + Assert.AreEqual(Visibility.Visible, dayTextBlock.Visibility); + Assert.AreEqual(0, flyoutButtonContentGrid.ColumnDefinitions.IndexOf(dayColumn)); - Assert.IsTrue(monthTextBlock.Visibility == Visibility.Collapsed); - Assert.IsFalse(flyoutButtonContentGrid.ColumnDefinitions.IndexOf(monthColumn) == 0); + Assert.AreEqual(Visibility.Collapsed, monthTextBlock.Visibility); + Assert.AreNotEqual(0, flyoutButtonContentGrid.ColumnDefinitions.IndexOf(monthColumn)); datePicker.MonthVisible = true; datePicker.YearVisible = false; @@ -680,11 +680,11 @@ await RunOnUIThread.ExecuteAsync(() => await TestServices.WindowHelper.WaitForIdle(); await RunOnUIThread.ExecuteAsync(() => { - Assert.IsTrue(monthTextBlock.Visibility == Visibility.Visible); - Assert.IsTrue(flyoutButtonContentGrid.ColumnDefinitions.IndexOf(monthColumn) == 0); + Assert.AreEqual(Visibility.Visible, monthTextBlock.Visibility); + Assert.AreEqual(0, flyoutButtonContentGrid.ColumnDefinitions.IndexOf(monthColumn)); - Assert.IsTrue(yearTextBlock.Visibility == Visibility.Collapsed); - Assert.IsFalse(flyoutButtonContentGrid.ColumnDefinitions.IndexOf(yearColumn) == 0); + Assert.AreEqual(Visibility.Collapsed, yearTextBlock.Visibility); + Assert.AreNotEqual(0, flyoutButtonContentGrid.ColumnDefinitions.IndexOf(yearColumn)); }); } @@ -770,13 +770,13 @@ await RunOnUIThread.ExecuteAsync(() => // The flyout popup, the flyout presenter and the button should have an RTL flow direction. // The DatePicker itself should remain in LTR flow direction. - Assert.AreEqual(datePicker.FlowDirection, FlowDirection.LeftToRight); - Assert.AreEqual(flyoutPopup.FlowDirection, FlowDirection.RightToLeft); - Assert.AreEqual(datepickerFlyoutPresenter.FlowDirection, FlowDirection.RightToLeft); - Assert.AreEqual(button.FlowDirection, FlowDirection.RightToLeft); + Assert.AreEqual(FlowDirection.LeftToRight, datePicker.FlowDirection); + Assert.AreEqual(FlowDirection.RightToLeft, flyoutPopup.FlowDirection); + Assert.AreEqual(FlowDirection.RightToLeft, datepickerFlyoutPresenter.FlowDirection); + Assert.AreEqual(FlowDirection.RightToLeft, button.FlowDirection); // The flyout presenter should be the same width as the datepicker. - Assert.IsTrue(datepickerFlyoutPresenter.ActualWidth == datePicker.ActualWidth); + Assert.AreEqual(datePicker.ActualWidth, datepickerFlyoutPresenter.ActualWidth); // For a Popup with RTL flowdirection, HorizontalOffset represents the Popup's RIGHT most edge from the LEFT most edge of the screen. // For a DatePickerFlyout, we expect its right-most edge to line up with the right-most edge of the DatePicker. @@ -1150,7 +1150,7 @@ void validatePlaceholder(TextBlock textBlock, string expectedPlaceholder) this.Log().InfoFormat("Expected placeholder: \"{0}\"", expectedPlaceholder); this.Log().InfoFormat("Actual text: \"{0}\"", textBlock.Text); - Assert.IsTrue(string.CompareOrdinal(expectedPlaceholder, textBlock.Text) == 0); + Assert.AreEqual(0, string.CompareOrdinal(expectedPlaceholder, textBlock.Text)); } ; @@ -1173,7 +1173,7 @@ void validateValue(TextBlock textBlock, string placeholder) this.Log().InfoFormat("Placeholder: \"{0}\"", placeholder); this.Log().InfoFormat("Actual text: \"{0}\"", textBlock.Text); - Assert.IsTrue(string.CompareOrdinal(placeholder, textBlock.Text) != 0); + Assert.AreNotEqual(0, string.CompareOrdinal(placeholder, textBlock.Text)); } ; diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_AutoSuggestBox.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_AutoSuggestBox.cs index 6d619b299fc3..00ae0e48989e 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_AutoSuggestBox.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_AutoSuggestBox.cs @@ -655,36 +655,36 @@ static void AutoSuggestBox_TextChanged(AutoSuggestBox s, AutoSuggestBoxTextChang await WindowHelper.WaitForIdle(); Assert.AreEqual(0, lv.SelectedIndex); Assert.IsTrue(popup.IsOpen); - Assert.AreEqual(keyDownHandled, 1); - Assert.AreEqual(keyDownNotHandled, 0); + Assert.AreEqual(1, keyDownHandled); + Assert.AreEqual(0, keyDownNotHandled); await KeyboardHelper.Down(); await WindowHelper.WaitForIdle(); Assert.AreEqual(1, lv.SelectedIndex); Assert.IsTrue(popup.IsOpen); - Assert.AreEqual(keyDownHandled, 2); - Assert.AreEqual(keyDownNotHandled, 0); + Assert.AreEqual(2, keyDownHandled); + Assert.AreEqual(0, keyDownNotHandled); await KeyboardHelper.Right(); await WindowHelper.WaitForIdle(); Assert.AreEqual(1, lv.SelectedIndex); Assert.IsTrue(popup.IsOpen); - Assert.AreEqual(keyDownHandled, 2); - Assert.AreEqual(keyDownNotHandled, 1); + Assert.AreEqual(2, keyDownHandled); + Assert.AreEqual(1, keyDownNotHandled); await KeyboardHelper.Left(); await WindowHelper.WaitForIdle(); Assert.AreEqual(1, lv.SelectedIndex); Assert.IsTrue(popup.IsOpen); - Assert.AreEqual(keyDownHandled, 3); // actually handled in textbox - Assert.AreEqual(keyDownNotHandled, 1); + Assert.AreEqual(3, keyDownHandled); // actually handled in textbox + Assert.AreEqual(1, keyDownNotHandled); await KeyboardHelper.Up(); await WindowHelper.WaitForIdle(); Assert.AreEqual(0, lv.SelectedIndex); Assert.IsTrue(popup.IsOpen); - Assert.AreEqual(keyDownHandled, 4); - Assert.AreEqual(keyDownNotHandled, 1); + Assert.AreEqual(4, keyDownHandled); + Assert.AreEqual(1, keyDownNotHandled); } finally { @@ -773,12 +773,12 @@ static void AutoSuggestBox_TextChanged(AutoSuggestBox s, AutoSuggestBoxTextChang await WindowHelper.WaitForIdle(); Assert.AreEqual(1, lv.SelectedIndex); Assert.IsTrue(popup.IsOpen); - Assert.AreEqual(keyDownHandled, 2); - Assert.AreEqual(keyDownNotHandled, 0); + Assert.AreEqual(2, keyDownHandled); + Assert.AreEqual(0, keyDownNotHandled); await KeyboardHelper.Enter(); - Assert.AreEqual(keyDownHandled, 3); - Assert.AreEqual(keyDownNotHandled, 0); + Assert.AreEqual(3, keyDownHandled); + Assert.AreEqual(0, keyDownNotHandled); } finally { @@ -869,8 +869,8 @@ static void AutoSuggestBox_TextChanged(AutoSuggestBox s, AutoSuggestBoxTextChang await WindowHelper.WaitForIdle(); Assert.AreEqual(1, lv.SelectedIndex); Assert.IsTrue(popup.IsOpen); - Assert.AreEqual(keyDownHandled, 2); - Assert.AreEqual(keyDownNotHandled, 0); + Assert.AreEqual(2, keyDownHandled); + Assert.AreEqual(0, keyDownNotHandled); if (escape) { @@ -880,8 +880,8 @@ static void AutoSuggestBox_TextChanged(AutoSuggestBox s, AutoSuggestBoxTextChang { await KeyboardHelper.Enter(); } - Assert.AreEqual(keyDownHandled, 3); - Assert.AreEqual(keyDownNotHandled, 0); + Assert.AreEqual(3, keyDownHandled); + Assert.AreEqual(0, keyDownNotHandled); } finally { diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Border.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Border.cs index 4c8a3a6df4b7..61b4e6af45f0 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Border.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Border.cs @@ -109,7 +109,7 @@ public async Task Check_Border_Margin(bool useCustomControl) //Assert.AreEqual(new Vector3((float)expectedOffsetDimension, (float)expectedOffsetDimension, 0), customControl.ActualOffset); Assert.AreEqual(expectedSizeInner, customControl.DesiredSize); - Assert.AreEqual(null, customControl.Clip); + Assert.IsNull(customControl.Clip); } // TODO: This assert currently fails. @@ -119,7 +119,7 @@ public async Task Check_Border_Margin(bool useCustomControl) Assert.AreEqual(new Size(innerDimension, innerDimension), innerBorder.RenderSize); Assert.AreEqual(new Vector2((float)innerDimension, (float)innerDimension), innerBorder.ActualSize); Assert.AreEqual(expectedSizeInner, innerBorder.DesiredSize); - Assert.AreEqual(null, innerBorder.Clip); + Assert.IsNull(innerBorder.Clip); } [TestMethod] @@ -630,10 +630,9 @@ protected override Size ArrangeOverride(Size finalSize) #if HAS_UNO #if !HAS_INPUT_INJECTOR [Ignore("InputInjector is not supported on this platform.")] -#else +#endif [TestMethod] [RunsOnUIThread] -#endif public async Task Nested_Element_Tapped() { var SUT = new Border() @@ -669,10 +668,9 @@ public async Task Nested_Element_Tapped() #if !HAS_INPUT_INJECTOR [Ignore("InputInjector is not supported on this platform.")] -#else +#endif [TestMethod] [RunsOnUIThread] -#endif public async Task Parent_DoubleTapped_When_Child_Has_Tapped() { var SUT = new Border() diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Button.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Button.cs index b56948707b50..d8e005a8d0a9 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Button.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Button.cs @@ -67,43 +67,43 @@ public async Task When_Enabled_Inside_Disabled_Control() await UITestHelper.Load(cc); // The button should be disabled because the outer control is disabled - Assert.AreEqual(cc.IsEnabled, false); - Assert.AreEqual(SUT.IsEnabled, false); + Assert.IsFalse(cc.IsEnabled); + Assert.IsFalse(SUT.IsEnabled); // Once the outer control is enabled, the button can control its own IsEnabled cc.IsEnabled = true; - Assert.AreEqual(cc.IsEnabled, true); - Assert.AreEqual(SUT.IsEnabled, true); + Assert.IsTrue(cc.IsEnabled); + Assert.IsTrue(SUT.IsEnabled); // We test once again to test behaviour when the value is set while running // instead of during initialization cc.IsEnabled = false; - Assert.AreEqual(cc.IsEnabled, false); - Assert.AreEqual(SUT.IsEnabled, false); + Assert.IsFalse(cc.IsEnabled); + Assert.IsFalse(SUT.IsEnabled); // Now let's make sure Button.IsEnabled doesn't // affect the outer ContentControl.IsEnabled // cc.IsEnbaled is false SUT.IsEnabled = true; - Assert.AreEqual(cc.IsEnabled, false); - Assert.AreEqual(SUT.IsEnabled, false); + Assert.IsFalse(cc.IsEnabled); + Assert.IsFalse(SUT.IsEnabled); SUT.IsEnabled = false; - Assert.AreEqual(cc.IsEnabled, false); - Assert.AreEqual(SUT.IsEnabled, false); + Assert.IsFalse(cc.IsEnabled); + Assert.IsFalse(SUT.IsEnabled); cc.IsEnabled = true; - Assert.AreEqual(cc.IsEnabled, true); - Assert.AreEqual(SUT.IsEnabled, false); + Assert.IsTrue(cc.IsEnabled); + Assert.IsFalse(SUT.IsEnabled); SUT.IsEnabled = true; - Assert.AreEqual(cc.IsEnabled, true); - Assert.AreEqual(SUT.IsEnabled, true); + Assert.IsTrue(cc.IsEnabled); + Assert.IsTrue(SUT.IsEnabled); SUT.IsEnabled = false; - Assert.AreEqual(cc.IsEnabled, true); - Assert.AreEqual(SUT.IsEnabled, false); + Assert.IsTrue(cc.IsEnabled); + Assert.IsFalse(SUT.IsEnabled); } [TestMethod] diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ComboBox.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ComboBox.cs index 5389e258e1a7..5bc84374673e 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ComboBox.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ComboBox.cs @@ -714,7 +714,7 @@ public async Task When_Collection_Reset() await WindowHelper.WaitForIdle(); - Assert.AreEqual(SUT.Items.Count, 3); + Assert.AreEqual(3, SUT.Items.Count); using (c.BatchUpdate()) { @@ -727,7 +727,7 @@ public async Task When_Collection_Reset() // Items are materialized when the popup is opened await WindowHelper.WaitForIdle(); - Assert.AreEqual(SUT.Items.Count, 5); + Assert.AreEqual(5, SUT.Items.Count); Assert.IsNotNull(SUT.ContainerFromItem("One")); Assert.IsNotNull(SUT.ContainerFromItem("Four")); Assert.IsNotNull(SUT.ContainerFromItem("Five")); @@ -818,7 +818,7 @@ public async Task When_Binding_Change() WindowHelper.WindowContent = SUT; SUT.DataContext = new { MySource = c, SelectedItem = "Two" }; - Assert.AreEqual(SUT.Items.Count, 12); + Assert.AreEqual(12, SUT.Items.Count); } finally { @@ -864,7 +864,7 @@ public async Task When_Full_Collection_Reset() // Not required on WinUI. Fixing this in Uno requires porting ComboBox. await WindowHelper.WaitForIdle(); - Assert.AreEqual(SUT.Items.Count, 3); + Assert.AreEqual(3, SUT.Items.Count); using (c.BatchUpdate()) { @@ -1182,7 +1182,7 @@ public async Task When_ComboBox_IsTextSearchEnabled_DropDown_Closed(bool isTextS comboBox.Focus(FocusState.Programmatic); Assert.AreEqual(-1, comboBox.SelectedIndex); - Assert.AreEqual(false, comboBox.IsDropDownOpen); + Assert.IsFalse(comboBox.IsDropDownOpen); await KeyboardHelper.PressKeySequence("$d$_r#$u$_r"); var expectedSelectedIndex = isTextSearchEnabled ? 2 : -1; diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CommandBar.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CommandBar.cs index 730bd0680d44..d81d1939bcbd 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CommandBar.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_CommandBar.cs @@ -116,23 +116,23 @@ public async Task When_Expanded_Then_Collapsed_MoreButton_VerticalAlignment() var moreButton = (Button)SUT.FindName("MoreButton"); #if !__ANDROID__ // layout timings are different on android - Assert.AreEqual(moreButton.ActualHeight, 48); + Assert.AreEqual(48, moreButton.ActualHeight); #endif - Assert.AreEqual(moreButton.VerticalAlignment, VerticalAlignment.Top); + Assert.AreEqual(VerticalAlignment.Top, moreButton.VerticalAlignment); SUT.IsOpen = true; await WindowHelper.WaitForIdle(); #if !__ANDROID__ // layout timings are different on android - Assert.AreEqual(moreButton.ActualHeight, 64); + Assert.AreEqual(64, moreButton.ActualHeight); #endif - Assert.AreEqual(moreButton.VerticalAlignment, VerticalAlignment.Stretch); + Assert.AreEqual(VerticalAlignment.Stretch, moreButton.VerticalAlignment); SUT.IsOpen = false; await Task.Delay(1000); // wait for animations #if !__ANDROID__ // layout timings are different on android - Assert.AreEqual(moreButton.ActualHeight, 48); + Assert.AreEqual(48, moreButton.ActualHeight); #endif - Assert.AreEqual(moreButton.VerticalAlignment, VerticalAlignment.Top); + Assert.AreEqual(VerticalAlignment.Top, moreButton.VerticalAlignment); } #if __IOS__ diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ContentControl.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ContentControl.cs index 5e8e9c518121..0d3ac184b754 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ContentControl.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ContentControl.cs @@ -125,15 +125,15 @@ public async Task When_ContentTemplateSelector_And_Default_Style() await WindowHelper.WaitForLoaded(control); control.Content = items[0]; var text1 = await WindowHelper.WaitForNonNull(() => control.FindFirstChild(tb => tb.Name == "TextBlockInTemplate"), message: $"Template selector not applied for {control.GetType()}"); - Assert.AreEqual(text1.Text, "Selectable A", $"Template selector not applied for {control.GetType()}"); + Assert.AreEqual("Selectable A", text1.Text, $"Template selector not applied for {control.GetType()}"); control.Content = items[1]; var text2 = await WindowHelper.WaitForNonNull(() => control.FindFirstChild(tb => tb.Name == "TextBlockInTemplate")); - Assert.AreEqual(text2.Text, "Selectable B"); + Assert.AreEqual("Selectable B", text2.Text); control.Content = items[2]; var text3 = await WindowHelper.WaitForNonNull(() => control.FindFirstChild(tb => tb.Name == "TextBlockInTemplate")); - Assert.AreEqual(text3.Text, "Selectable C"); + Assert.AreEqual("Selectable C", text3.Text); } } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs index 773d1600ad2c..5f9b3d03d623 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Flyout.cs @@ -600,14 +600,14 @@ public async Task When_Flyout_Content_Takes_Focus() var popup = VisualTreeHelper.GetOpenPopupsForXamlRoot(flyoutButton.XamlRoot)[0]; - Assert.AreEqual(popup.Visibility, Visibility.Visible); + Assert.AreEqual(Visibility.Visible, popup.Visibility); Assert.AreNotEqual(button, FocusManager.GetFocusedElement(TestServices.WindowHelper.XamlRoot)); flyout.Hide(); await TestServices.WindowHelper.WaitForIdle(); // The visibility of the popup remains on, but it's closed. - Assert.AreEqual(popup.Visibility, Visibility.Visible); + Assert.AreEqual(Visibility.Visible, popup.Visibility); Assert.AreEqual(button, FocusManager.GetFocusedElement(TestServices.WindowHelper.XamlRoot)); TestServices.WindowHelper.WindowContent = null; diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Frame.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Frame.cs index 0d2d432f2c82..d41714e84e7c 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Frame.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Frame.cs @@ -60,7 +60,7 @@ public Task When_Page_Loaded_Navigates_Without_Yield() => public Task When_Page_Loaded_Navigates_With_Yield() => When_Page_Loaded_Navigates_Inner(true); - public async Task When_Page_Loaded_Navigates_Inner(bool yield) + private async Task When_Page_Loaded_Navigates_Inner(bool yield) { var frame = new Frame(); TestServices.WindowHelper.WindowContent = frame; @@ -329,8 +329,8 @@ void OnPageNavigatedTo(object sender, EventArgs args) Assert.AreEqual(navigatedCurrentSourcePageType, SUT.SourcePageType); }; - Assert.AreEqual(null, SUT.SourcePageType); - Assert.AreEqual(null, SUT.CurrentSourcePageType); + Assert.IsNull(SUT.SourcePageType); + Assert.IsNull(SUT.CurrentSourcePageType); // Navigate from null to SourceTypePage1 diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_FrameworkTemplatePool.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_FrameworkTemplatePool.cs index 0a4cacb251c2..bb6a246b1899 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_FrameworkTemplatePool.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_FrameworkTemplatePool.cs @@ -201,7 +201,7 @@ void AssertEditorContents() Assert.IsTrue(vm.Editors.All(e => !string.IsNullOrEmpty(e.Text))); Assert.IsTrue(vm.Editors.All(e => e.IsChecked)); Assert.IsTrue(vm.Editors.All(e => e.IsOn)); - Assert.IsTrue(!string.IsNullOrEmpty(textBox.Text)); + Assert.IsFalse(string.IsNullOrEmpty(textBox.Text)); Assert.IsTrue(checkBox.IsChecked); Assert.IsTrue(toggleSwitch.IsOn); Assert.AreEqual(vm.CurrentEditor.IsChecked, checkBox.IsChecked); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs index 197700f0b569..d7a763b4b047 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_Image.cs @@ -80,9 +80,10 @@ public async Task When_Parent_Has_BorderThickness() Assert.AreEqual(new Rect(68, 41, 11, 17), pinkBounds); } -#if !__IOS__ // Currently fails on iOS - [TestMethod] +#if __IOS__ + [Ignore("Currently fails on iOS")] #endif + [TestMethod] [RunsOnUIThread] public async Task When_Fixed_Height_And_Stretch_Uniform() { diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ItemsPresenter.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ItemsPresenter.cs index 8e31d6ea5f01..8ed3830f21d6 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ItemsPresenter.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ItemsPresenter.cs @@ -1131,12 +1131,12 @@ public async Task When_Header_Template() var SUT = ic.FindVisualChildByType(); - Assert.AreEqual(SUT.FindVisualChildByType().Text, "initial header value"); + Assert.AreEqual("initial header value", SUT.FindVisualChildByType().Text); SUT.Header = "updated header value"; await WindowHelper.WaitForIdle(); - Assert.AreEqual(SUT.FindVisualChildByType().Text, "updated header value"); + Assert.AreEqual("updated header value", SUT.FindVisualChildByType().Text); } [TestMethod] @@ -1172,12 +1172,12 @@ public async Task When_Footer_Template() var SUT = ic.FindVisualChildByType(); - Assert.AreEqual(SUT.FindVisualChildByType().Text, "initial footer value"); + Assert.AreEqual("initial footer value", SUT.FindVisualChildByType().Text); SUT.Footer = "updated footer value"; await WindowHelper.WaitForIdle(); - Assert.AreEqual(SUT.FindVisualChildByType().Text, "updated footer value"); + Assert.AreEqual("updated footer value", SUT.FindVisualChildByType().Text); } [TestMethod] diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs index 9964e8e2e85a..2df082b334e2 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ListViewBase.cs @@ -564,7 +564,7 @@ public async Task SingleItemSelected() await TestServices.WindowHelper.WaitForIdle(); - Assert.AreEqual(list.SelectedIndex, 0); + Assert.AreEqual(0, list.SelectedIndex); Assert.AreEqual(list.SelectedItem, child1); } @@ -610,6 +610,7 @@ public async Task MultipleItemsSelected() Assert.AreEqual(list.SelectedItems[1], child3); } + [TestMethod] public async Task NoItemSelectedMultiple() { var child1 = new ListViewItem @@ -644,7 +645,7 @@ public async Task NoItemSelectedMultiple() await TestServices.WindowHelper.WaitForIdle(); - Assert.AreEqual(list.SelectedItems.Count, 0); + Assert.AreEqual(0, list.SelectedItems.Count); } [TestMethod] @@ -683,7 +684,7 @@ public async Task NoItemSelectedSingle() await TestServices.WindowHelper.WaitForIdle(); - Assert.AreEqual(list.SelectedIndex, -1); + Assert.AreEqual(-1, list.SelectedIndex); } [TestMethod] @@ -903,8 +904,8 @@ public async Task When_Multiple_Selection_Pointer() async Task AssertSelected() { await WindowHelper.WaitForIdle(); - selected.ForEach(item => Assert.AreEqual(item.IsSelected, true)); - items.Except(selected).ForEach(item => Assert.AreEqual(item.IsSelected, false)); + selected.ForEach(item => Assert.IsTrue(item.IsSelected)); + items.Except(selected).ForEach(item => Assert.IsFalse(item.IsSelected)); } } #endif @@ -964,8 +965,8 @@ public async Task When_Multiple_Selection_Keyboard() async Task AssertSelected() { await WindowHelper.WaitForIdle(); - selected.ForEach(item => Assert.AreEqual(item.IsSelected, true)); - items.Except(selected).ForEach(item => Assert.AreEqual(item.IsSelected, false)); + selected.ForEach(item => Assert.IsTrue(item.IsSelected)); + items.Except(selected).ForEach(item => Assert.IsFalse(item.IsSelected)); } } #endif @@ -1045,8 +1046,8 @@ public async Task When_Extended_Selection_Pointer() async Task AssertSelected() { await WindowHelper.WaitForIdle(); - selected.ForEach(item => Assert.AreEqual(item.IsSelected, true)); - items.Except(selected).ForEach(item => Assert.AreEqual(item.IsSelected, false)); + selected.ForEach(item => Assert.IsTrue(item.IsSelected)); + items.Except(selected).ForEach(item => Assert.IsFalse(item.IsSelected)); } } #endif @@ -1123,8 +1124,8 @@ public async Task When_Extended_Selection_Keyboard() async Task AssertSelected() { await WindowHelper.WaitForIdle(); - selected.ForEach(item => Assert.AreEqual(item.IsSelected, true)); - items.Except(selected).ForEach(item => Assert.AreEqual(item.IsSelected, false)); + selected.ForEach(item => Assert.IsTrue(item.IsSelected)); + items.Except(selected).ForEach(item => Assert.IsFalse(item.IsSelected)); } } #endif @@ -1175,8 +1176,8 @@ public async Task When_Extended_Selection_SelectedIndex_Changed_Keyboard() async Task AssertSelected() { await WindowHelper.WaitForIdle(); - selected.ForEach(item => Assert.AreEqual(item.IsSelected, true)); - items.Except(selected).ForEach(item => Assert.AreEqual(item.IsSelected, false)); + selected.ForEach(item => Assert.IsTrue(item.IsSelected)); + items.Except(selected).ForEach(item => Assert.IsFalse(item.IsSelected)); } } #endif @@ -1233,8 +1234,8 @@ public async Task When_Extended_Selection_SelectedIndex_Changed_Mixed() async Task AssertSelected() { await WindowHelper.WaitForIdle(); - selected.ForEach(item => Assert.AreEqual(item.IsSelected, true)); - items.Except(selected).ForEach(item => Assert.AreEqual(item.IsSelected, false)); + selected.ForEach(item => Assert.IsTrue(item.IsSelected)); + items.Except(selected).ForEach(item => Assert.IsFalse(item.IsSelected)); } } #endif @@ -1436,8 +1437,8 @@ public void When_Selection_SelectedValuePath_Set() SUT.ItemsSource = source; SUT.SelectedValuePath = "Key"; - Assert.AreEqual(null, SUT.SelectedValue); - Assert.AreEqual(null, SUT.SelectedItem); + Assert.IsNull(SUT.SelectedValue); + Assert.IsNull(SUT.SelectedItem); Assert.AreEqual(-1, SUT.SelectedIndex); SUT.SelectedValue = 1; @@ -1450,8 +1451,8 @@ public void When_Selection_SelectedValuePath_Set() // Set invalid SUT.SelectedValue = 4; - Assert.AreEqual(null, SUT.SelectedValue); - Assert.AreEqual(null, SUT.SelectedItem); + Assert.IsNull(SUT.SelectedValue); + Assert.IsNull(SUT.SelectedItem); Assert.AreEqual(-1, SUT.SelectedIndex); } @@ -1467,8 +1468,8 @@ public void When_Selection_SelectedValue_Path_Not_Set() }; SUT.ItemsSource = source; - Assert.AreEqual(null, SUT.SelectedValue); - Assert.AreEqual(null, SUT.SelectedItem); + Assert.IsNull(SUT.SelectedValue); + Assert.IsNull(SUT.SelectedItem); Assert.AreEqual(-1, SUT.SelectedIndex); SUT.SelectedValue = "Two"; @@ -1479,8 +1480,8 @@ public void When_Selection_SelectedValue_Path_Not_Set() SUT.SelectedValue = "Eleventy"; - Assert.AreEqual(null, SUT.SelectedValue); - Assert.AreEqual(null, SUT.SelectedItem); + Assert.IsNull(SUT.SelectedValue); + Assert.IsNull(SUT.SelectedItem); Assert.AreEqual(-1, SUT.SelectedIndex); } @@ -2430,7 +2431,7 @@ public async Task When_Items_Their_Own_Container_In_OnItemsChanged_Removal() Assert.AreEqual(0, list.IndexFromContainer(items[0])); // Test removed container/index/item - Assert.AreEqual(null, list.ContainerFromItem(removedItem)); + Assert.IsNull(list.ContainerFromItem(removedItem)); // In UWP, the Item is returned even though it is already removed // This is a weird behavior and doesn't seem too useful anyway, so we currently // ignore it @@ -2545,8 +2546,8 @@ public async Task When_Items_Their_Own_Container_In_OnItemsChanged_Change() Assert.AreEqual(0, list.IndexFromContainer(items[0])); // Test old container/index/item - Assert.AreEqual(null, list.ContainerFromItem(oldItem)); - Assert.AreEqual(null, list.ItemFromContainer(oldItem)); + Assert.IsNull(list.ContainerFromItem(oldItem)); + Assert.IsNull(list.ItemFromContainer(oldItem)); Assert.AreEqual(-1, list.IndexFromContainer(oldItem)); // Test new container/index/item @@ -2603,8 +2604,8 @@ public async Task When_Items_Their_Own_Container_In_OnItemsChanged_Reset() using var _ = new AssertionScope(); // Test container/index/item from old source - Assert.AreEqual(null, list.ContainerFromItem(items[1])); - Assert.AreEqual(null, list.ItemFromContainer(items[1])); + Assert.IsNull(list.ContainerFromItem(items[1])); + Assert.IsNull(list.ItemFromContainer(items[1])); Assert.AreEqual(-1, list.IndexFromContainer(items[1])); // Test container/index/item from new source @@ -2686,7 +2687,7 @@ public async Task When_Items_Not_Their_Own_Container_In_OnItemsChanged_Removal() Assert.AreEqual(0, list.IndexFromContainer(container0)); // Test removed container/index/item - Assert.AreEqual(null, list.ContainerFromItem(removedItem)); + Assert.IsNull(list.ContainerFromItem(removedItem)); // Test container/index/item right after removed var container1 = (ListViewItem)list.ContainerFromItem(items[1]); @@ -2806,8 +2807,8 @@ public async Task When_Items_Not_Their_Own_Container_In_OnItemsChanged_Change() Assert.AreEqual(0, list.IndexFromContainer(container0)); // Test old container/index/item - Assert.AreEqual(null, list.ContainerFromItem(oldItem)); - Assert.AreEqual(null, list.ItemFromContainer(oldContainer)); + Assert.IsNull(list.ContainerFromItem(oldItem)); + Assert.IsNull(list.ItemFromContainer(oldContainer)); Assert.AreEqual(-1, list.IndexFromContainer(oldContainer)); #if HAS_UNO @@ -2876,8 +2877,8 @@ public async Task When_Items_Not_Their_Own_Container_In_OnItemsChanged_Reset() using var _ = new AssertionScope(); // Test container/index/item from old source - Assert.AreEqual(null, list.ContainerFromItem(oldItem)); - Assert.AreEqual(null, list.ItemFromContainer(oldContainer)); + Assert.IsNull(list.ContainerFromItem(oldItem)); + Assert.IsNull(list.ItemFromContainer(oldContainer)); Assert.AreEqual(-1, list.IndexFromContainer(oldContainer)); // Test container/index/item from new source @@ -2915,17 +2916,17 @@ public async Task When_ItemTemplateSelector_Set() var container1 = await WindowHelper.WaitForNonNull(() => list.ContainerFromIndex(0) as ListViewItem); var text1 = container1.FindFirstDescendant(tb => tb.Name == "TextBlockInTemplate"); Assert.IsNotNull(text1); - Assert.AreEqual(text1.Text, "Selectable A"); + Assert.AreEqual("Selectable A", text1.Text); var container2 = await WindowHelper.WaitForNonNull(() => list.ContainerFromIndex(1) as ListViewItem); var text2 = container2.FindFirstDescendant(tb => tb.Name == "TextBlockInTemplate"); Assert.IsNotNull(text2); - Assert.AreEqual(text2.Text, "Selectable B"); + Assert.AreEqual("Selectable B", text2.Text); var container3 = await WindowHelper.WaitForNonNull(() => list.ContainerFromIndex(2) as ListViewItem); var text3 = container3.FindFirstDescendant(tb => tb.Name == "TextBlockInTemplate"); Assert.IsNotNull(text3); - Assert.AreEqual(text3.Text, "Selectable C"); + Assert.AreEqual("Selectable C", text3.Text); } [TestMethod] @@ -3004,7 +3005,7 @@ await WindowHelper.WaitForEqual(0, () => }); Assert.AreEqual(-1, list.SelectedIndex); - Assert.AreEqual(null, list.SelectedItem); + Assert.IsNull(list.SelectedItem); } [TestMethod] @@ -3034,7 +3035,7 @@ public async Task When_Selection_Events() { Assert.AreEqual(list.SelectedItem, "Item_1"); Assert.AreEqual(list.SelectedValue, "Item_1"); - Assert.AreEqual(model.SelectedIndex, 1); + Assert.AreEqual(1, model.SelectedIndex); Assert.AreEqual(model.SelectedItem, "Item_1"); Assert.AreEqual(model.SelectedValue, "Item_1"); }; @@ -3920,7 +3921,7 @@ public async Task When_SelectionMode_Is_Multiple() var vsg = vsgs?.FirstOrDefault(x => x.Name == "MultiSelectStates"); Assert.IsNotNull(vsg, "VisualStateGroup[Name=MultiSelectStates] was not found."); - Assert.AreEqual(vsg.CurrentState?.Name, "MultiSelectEnabled"); + Assert.AreEqual("MultiSelectEnabled", vsg.CurrentState?.Name); } #if HAS_UNO @@ -3952,12 +3953,12 @@ public async Task Valid_MultipleSelectionMode_ValidSelectionStates() Assert.IsNotNull(mscfe, "MultiSelectCheck was not found."); Assert.IsNotNull(vsgMultiSelectStates, "VisualStateGroup[Name=MultiSelectStates] was not found."); Assert.IsNotNull(vsgCommonStates, "VisualStateGroup[Name=CommonStates] was not found."); - Assert.AreEqual(vsgMultiSelectStates.CurrentState?.Name, "MultiSelectEnabled"); - Assert.AreNotEqual(vsgCommonStates.CurrentState?.Name, "Selected"); - Assert.AreEqual(mscfe.Opacity, 0); + Assert.AreEqual("MultiSelectEnabled", vsgMultiSelectStates.CurrentState?.Name); + Assert.AreNotEqual("Selected", vsgCommonStates.CurrentState?.Name); + Assert.AreEqual(0, mscfe.Opacity); lvi0.IsSelected = true; - Assert.AreEqual(vsgCommonStates.CurrentState?.Name, "Selected"); - Assert.AreEqual(mscfe.Opacity, 1); + Assert.AreEqual("Selected", vsgCommonStates.CurrentState?.Name); + Assert.AreEqual(1, mscfe.Opacity); } #endif @@ -4376,7 +4377,7 @@ public async Task When_ThemeChange() Assert.AreEqual(Colors.White, ((SolidColorBrush)tb.Foreground).Color); } - Assert.AreEqual(true, seenNewTextBlock); + Assert.IsTrue(seenNewTextBlock); } } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_MediaPlayerElement.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_MediaPlayerElement.cs index 24589fd90ec4..440e9d4dbdd5 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_MediaPlayerElement.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_MediaPlayerElement.cs @@ -295,11 +295,11 @@ public async Task When_MediaPlayerElement_Check_TransportControlVisibility() var root = (WindowHelper.XamlRoot?.Content as FrameworkElement)!; var tcp = (FrameworkElement)root.FindName("TransportControlsPresenter"); - Assert.AreEqual(tcp.Visibility, Visibility.Collapsed); + Assert.AreEqual(Visibility.Collapsed, tcp.Visibility); sut.AreTransportControlsEnabled = true; - Assert.AreEqual(tcp.Visibility, Visibility.Visible); + Assert.AreEqual(Visibility.Visible, tcp.Visibility); sut.AreTransportControlsEnabled = false; - Assert.AreEqual(tcp.Visibility, Visibility.Collapsed); + Assert.AreEqual(Visibility.Collapsed, tcp.Visibility); } #if !HAS_UNO @@ -584,11 +584,7 @@ await WindowHelper.WaitFor( ); } - - - - - public void CheckMediaPlayerExtensionAvailability() + private void CheckMediaPlayerExtensionAvailability() { #if HAS_UNO if (_MediaPlayer.ImplementedByExtensions && !ApiExtensibility.IsRegistered()) diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_MenuFlyout.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_MenuFlyout.cs index a976bcf1725d..0ae6bd49ccc1 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_MenuFlyout.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_MenuFlyout.cs @@ -104,7 +104,7 @@ public async Task When_Native_AppBarButton_And_Managed_Popups() { await ControlHelper.DoClickUsingAP(page.SUT); #if !WINAPPSDK - Assert.AreEqual(false, flyout.UseNativePopup); + Assert.IsFalse(flyout.UseNativePopup); #endif var flyoutItem = page.FirstFlyoutItem; @@ -452,7 +452,7 @@ public async Task When_MenuFlyout_DataContext_Changes_In_Opening() flyout.ShowAt(button); await WindowHelper.WaitForIdle(); - Assert.AreEqual((flyout.Items[0] as MenuFlyoutItem)!.Text, "1"); + Assert.AreEqual("1", (flyout.Items[0] as MenuFlyoutItem)!.Text); } finally { diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ScrollViewer.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ScrollViewer.cs index 7526fe32838c..7a82e35f3ef6 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ScrollViewer.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_ScrollViewer.cs @@ -89,7 +89,7 @@ public async Task When_NonScrollableScroller_Then_DoNotLoadAllTemplate() .OfType() .Count(); - Assert.IsTrue(buttons == 0); + Assert.AreEqual(0, buttons); } [TestMethod] @@ -137,7 +137,7 @@ public async Task When_HorizontallyScrollableTextBox_Then_DoNotLoadAllScrollerTe .OfType() .Count(); - Assert.IsTrue(bars == 0); // TextBox is actually not using scrollbars! + Assert.AreEqual(0, bars); // TextBox is actually not using scrollbars! } [TestMethod] @@ -157,7 +157,7 @@ public async Task When_NonScrollableTextBox_Then_DoNotLoadAllScrollerTemplate() .OfType() .Count(); - Assert.IsTrue(bars == 0); // TextBox is actually not using scrollbars! + Assert.AreEqual(0, bars); // TextBox is actually not using scrollbars! } #endif @@ -973,8 +973,8 @@ public async Task When_Nested_Scroll_BringIntoView() item.BringIntoViewRequested += (s, e) => { - Assert.AreEqual(false, e.AnimationDesired); - Assert.AreEqual(false, e.Handled); + Assert.IsFalse(e.AnimationDesired); + Assert.IsFalse(e.Handled); Assert.IsTrue(double.IsNaN(e.HorizontalAlignmentRatio)); Assert.IsTrue(double.IsNaN(e.VerticalAlignmentRatio)); Assert.AreEqual(0, e.HorizontalOffset); @@ -986,8 +986,8 @@ public async Task When_Nested_Scroll_BringIntoView() innerScrollViewer.BringIntoViewRequested += (s, e) => { - Assert.AreEqual(false, e.AnimationDesired); - Assert.AreEqual(false, e.Handled); + Assert.IsFalse(e.AnimationDesired); + Assert.IsFalse(e.Handled); Assert.IsTrue(double.IsNaN(e.HorizontalAlignmentRatio)); Assert.IsTrue(double.IsNaN(e.VerticalAlignmentRatio)); Assert.AreEqual(0, e.HorizontalOffset); @@ -1001,8 +1001,8 @@ public async Task When_Nested_Scroll_BringIntoView() outerScrollViewer.BringIntoViewRequested += (s, e) => { - Assert.AreEqual(false, e.AnimationDesired); - Assert.AreEqual(false, e.Handled); + Assert.IsFalse(e.AnimationDesired); + Assert.IsFalse(e.Handled); Assert.IsTrue(double.IsNaN(e.HorizontalAlignmentRatio)); Assert.IsTrue(double.IsNaN(e.VerticalAlignmentRatio)); Assert.AreEqual(0, e.HorizontalOffset); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs index e9566393b64b..6149c39d8bc2 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBlock.cs @@ -893,7 +893,7 @@ public async Task When_TextTrimmingNone() await WindowHelper.WaitForIdle(); // necessary on ios, since the container finished loading before the text is drawn Assert.IsFalse(sut.IsTextTrimmed, "IsTextTrimmed should not be trimmed."); - Assert.IsTrue(states.Count == 0, $"IsTextTrimmedChanged should not proc at all. states: {(string.Join(", ", states) is string { Length: > 0 } tmp ? tmp : "(-empty-)")}"); + Assert.AreEqual(0, states.Count, $"IsTextTrimmedChanged should not proc at all. states: {(string.Join(", ", states) is string { Length: > 0 } tmp ? tmp : "(-empty-)")}"); } #endif diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs index 31b56fd8ce12..bfb5d41fba71 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs @@ -916,7 +916,7 @@ public async Task When_Paste() SUT.PasteFromClipboard(); await WindowHelper.WaitForIdle(); - Assert.AreEqual(pasteCount, 1); + Assert.AreEqual(1, pasteCount); } [TestMethod] @@ -1090,21 +1090,21 @@ public async Task When_Clicking_Outside_ContentElement_Should_Focus() using var mouse = injector.GetMouse(); mouse.MoveTo(clickPosition2); - Assert.IsTrue(list.Count == 0); + Assert.AreEqual(0, list.Count); mouse.Press(clickPosition2); await WindowHelper.WaitForIdle(); mouse.Release(); await WindowHelper.WaitForIdle(); - Assert.IsTrue(list.Count == 1); + Assert.AreEqual(1, list.Count); Assert.AreEqual("Second", list[0]); mouse.MoveTo(clickPosition1); - Assert.IsTrue(list.Count == 1); + Assert.AreEqual(1, list.Count); mouse.Press(clickPosition1); await WindowHelper.WaitForIdle(); mouse.Release(); await WindowHelper.WaitForIdle(); - Assert.IsTrue(list.Count == 2); + Assert.AreEqual(2, list.Count); Assert.AreEqual("First", list[1]); FocusManager.GotFocus -= FocusManager_GotFocus; diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs index 0416e472139f..e0af091cdbc0 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs @@ -1390,7 +1390,7 @@ public async Task When_Move_Caret_While_Pointer_Held(VirtualKey key, VirtualKeyM SUT.SafeRaiseEvent(UIElement.KeyDownEvent, new KeyRoutedEventArgs(SUT, key, modifiers)); await WindowHelper.WaitForIdle(); - Assert.AreEqual(false, handled); + Assert.IsFalse(handled); Assert.AreEqual("Hello world", SUT.Text); Assert.AreEqual(1, SUT.SelectionStart); Assert.AreEqual(9, SUT.SelectionLength); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/Given_BindableNullableValueType.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/Given_BindableNullableValueType.cs index a024b2222c0d..db0044def130 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/Given_BindableNullableValueType.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/Given_BindableNullableValueType.cs @@ -18,6 +18,6 @@ public void When_BindableNullableValueTypeTestPage() tb.Tag = "10"; Assert.AreEqual(10, x.MyProperty); tb.Tag = null; - Assert.AreEqual(null, x.MyProperty); + Assert.IsNull(x.MyProperty); } } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/Given_ISelectionInfo.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/Given_ISelectionInfo.cs index bad707febcea..8399769964ee 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/Given_ISelectionInfo.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Data/Given_ISelectionInfo.cs @@ -36,7 +36,7 @@ public async Task When_SelectOne() lv.SelectedIndex = 3; - Assert.AreEqual(true, source.IsSelected(3), "source.IsSelected(3) == true"); + Assert.IsTrue(source.IsSelected(3), "source.IsSelected(3) == true"); Assert.AreEqual(1, selectionRanges.Count, "selectionRanges.Count == 1"); var expectedRange = new ItemIndexRange(3, 1); Assert.AreEqual(expectedRange.FirstIndex, selectionRanges[0].FirstIndex, "selectionRanges[0] == { 3..3, count = 1 }"); @@ -76,9 +76,9 @@ public async Task When_SelectOne_Denied() lv.SelectedIndex = 3; - Assert.AreEqual(false, source.IsSelected(3), "source.IsSelected(3) == false"); + Assert.IsFalse(source.IsSelected(3), "source.IsSelected(3) == false"); Assert.AreEqual(-1, lv.SelectedIndex, "lv.SelectedIndex == -1"); - Assert.AreEqual(null, lv.SelectedItem, "lv.SelectedItem == null"); + Assert.IsNull(lv.SelectedItem, "lv.SelectedItem == null"); } private class SelectionData diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_MarkupExtension.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_MarkupExtension.cs index 023d76c16773..b1ebc5cb4321 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_MarkupExtension.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_MarkupExtension.cs @@ -32,7 +32,7 @@ public void When_MarkupExtension_Default() var property = (ProvideValueTargetProperty)pvt.TargetProperty; Assert.AreEqual(pvt.TargetObject, sut); - Assert.AreEqual(property.Name, nameof(TextBlock.Tag)); + Assert.AreEqual(nameof(TextBlock.Tag), property.Name); Assert.AreEqual(rop.RootObject, page); } @@ -48,7 +48,7 @@ public void When_MarkupExtension_Nested() var property = (ProvideValueTargetProperty)pvt.TargetProperty; Assert.IsInstanceOfType(pvt.TargetObject, typeof(Binding)); - Assert.AreEqual(property.Name, nameof(Binding.Source)); + Assert.AreEqual(nameof(Binding.Source), property.Name); Assert.AreEqual(rop.RootObject, page); } @@ -65,7 +65,7 @@ public async Task When_MarkupExtension_ResourceDictionary1() var property = (ProvideValueTargetProperty)pvt.TargetProperty; Assert.AreEqual(pvt.TargetObject, sut); - Assert.AreEqual(property.Name, nameof(TextBlock.Tag)); + Assert.AreEqual(nameof(TextBlock.Tag), property.Name); Assert.IsInstanceOfType(rop.RootObject, typeof(ResourceDictionary)); } @@ -82,7 +82,7 @@ public async Task When_MarkupExtension_ResourceDictionary2() var property = (ProvideValueTargetProperty)pvt.TargetProperty; Assert.AreEqual(pvt.TargetObject, sut); - Assert.AreEqual(property.Name, nameof(TextBlock.Tag)); + Assert.AreEqual(nameof(TextBlock.Tag), property.Name); Assert.IsInstanceOfType(rop.RootObject, typeof(ResourceDictionary)); } diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_XamlReader.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_XamlReader.cs index b071890bab86..8d99103db886 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_XamlReader.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Markup/Given_XamlReader.cs @@ -309,7 +309,7 @@ public void When_TemplateBinding_AttachedProperty() var sut = setup.FindFirstDescendant(x => x.Name == "SUT"); var expr = sut.GetBindingExpression(ScrollViewer.HorizontalScrollModeProperty); - Assert.AreEqual(expr.ParentBinding.Path.Path, "(Microsoft.UI.Xaml.Controls:ScrollViewer.HorizontalScrollMode)"); + Assert.AreEqual("(Microsoft.UI.Xaml.Controls:ScrollViewer.HorizontalScrollMode)", expr.ParentBinding.Path.Path); Assert.AreEqual(ScrollMode.Disabled, sut.HorizontalScrollMode); ScrollViewer.SetHorizontalScrollMode(setup, ScrollMode.Enabled); Assert.AreEqual(ScrollMode.Enabled, sut.HorizontalScrollMode); diff --git a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/Given_DoubleAnimation.cs b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/Given_DoubleAnimation.cs index 99d374b3a966..7f66e692ac79 100644 --- a/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/Given_DoubleAnimation.cs +++ b/src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media_Animation/Given_DoubleAnimation.cs @@ -322,8 +322,8 @@ public async Task When_OverridingFillingValue_WithLocalValue(bool skipToFill) translate.Y = 312.0; var afterValue = translate.Y; - Assert.AreEqual(beforeValue, 100.0, "before: Should be animated to 100"); - Assert.AreEqual(afterValue, 312.0, "after: Should be set to 312"); + Assert.AreEqual(100.0, beforeValue, "before: Should be animated to 100"); + Assert.AreEqual(312.0, afterValue, "after: Should be set to 312"); } #if __ANDROID__