Repository: unoplatform/uno
File: src/Uno.UI.RuntimeTests/MUX/Microsoft_UI_Xaml_Controls/TabView/TabViewTests.Uno.cs (C#)

Code before:
			tabItem3.Content = new Border() { Background = new SolidColorBrush(Colors.Red) };

			tabView.TabItems.Add(tabItem1);
			tabView.TabItems.Add(tabItem2);
			tabView.TabItems.Add(tabItem3);

			var tabToSelectAndClose = tabView.TabItems[tabToClose];
			var expectedSelectedTabAfterClose = (TabViewItem)tabView.TabItems[expectedSelectedTab];
			var expectedColor = ((SolidColorBrush)((Border)expectedSelectedTabAfterClose.Content).Background).Color;

			TestServices.WindowHelper.WindowContent = tabView;
			await TestServices.WindowHelper.WaitForLoaded(tabView);

			// Select the tab that will be closed
			tabView.SelectedItem = tabToSelectAndClose;
			await TestServices.WindowHelper.WaitForIdle();

			// Close the tab
			tabView.TabItems.Remove(tabToSelectAndClose);
			await TestServices.WindowHelper.WaitForIdle();

			// Verify that the last tab is closed and the second last tab is selected
			Assert.IsFalse(tabView.TabItems.Contains(tabToSelectAndClose), "Expected the tab to be removed from the TabItems collection.");
			Assert.AreEqual(expectedSelectedTabAfterClose, tabView.SelectedItem, "Expected different tab to be selected after closing the selected tab.");

#if HAS_RENDER_TARGET_BITMAP
			var contentScreenshot = await UITestHelper.ScreenShot(tabView);
			ImageAssert.HasColorAt(contentScreenshot, contentScreenshot.Width / 2, contentScreenshot.Height / 2, expectedColor);
#endif
		}
	}
}


Review comment (suggestion):
```suggestion
			Assert.AreEqual(expectedSelectedTabAfterClose, tabView.SelectedItem, "Expected different tab to be selected after closing the selected tab.");
			Assert.IsTrue(expectedSelectedTabAfterClose.IsSelected, "Expected tab is not selected.");
```

Code after:
			tabItem2.Content = new Border() { Background = new SolidColorBrush(Colors.Green) };
			var tabItem3 = CreateTabViewItem("Item 3");
			tabItem3.Content = new Border() { Background = new SolidColorBrush(Colors.Red) };

			tabView.TabItems.Add(tabItem1);
			tabView.TabItems.Add(tabItem2);
			tabView.TabItems.Add(tabItem3);

			var tabToSelectAndClose = tabView.TabItems[tabToClose];
			var expectedSelectedTabAfterClose = (TabViewItem)tabView.TabItems[expectedSelectedTab];
			var expectedColor = ((SolidColorBrush)((Border)expectedSelectedTabAfterClose.Content).Background).Color;

			TestServices.WindowHelper.WindowContent = tabView;
			await TestServices.WindowHelper.WaitForLoaded(tabView);

			// Select the tab that will be closed
			tabView.SelectedItem = tabToSelectAndClose;
			await TestServices.WindowHelper.WaitForIdle();

			// Close the tab
			tabView.TabItems.Remove(tabToSelectAndClose);
			await TestServices.WindowHelper.WaitForIdle();

			// Verify that the last tab is closed and the second last tab is selected
			Assert.IsFalse(tabView.TabItems.Contains(tabToSelectAndClose), "Expected the tab to be removed from the TabItems collection.");
			Assert.AreEqual(expectedSelectedTabAfterClose, tabView.SelectedItem, "Expected different tab to be selected after closing the selected tab.");
			Assert.IsTrue(expectedSelectedTabAfterClose.IsSelected, "Expected tab is not selected.");

#if HAS_UNO
			var presenter = tabView.FindFirstDescendant<ContentPresenter>("TabContentPresenter");
			Assert.AreEqual(presenter.Content, expectedSelectedTabAfterClose.Content);
#endif
		}
	}
}