mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
Address code review feedback in test code
- Changed magic number to const InitialTemplateCount - Fixed potential index out of bounds by using All() with proper null check - Added System.Linq using directive Co-authored-by: niels9001 <9866362+niels9001@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FancyZonesEditor.Models;
|
||||
using FancyZonesEditorCommon.Data;
|
||||
using Microsoft.FancyZonesEditor.UnitTests.Utils;
|
||||
@@ -369,7 +370,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
public void DeleteTemplateLayout()
|
||||
{
|
||||
var deletedLayoutName = TestConstants.TemplateLayoutNames[LayoutType.Focus];
|
||||
var initialTemplateCount = 6; // Blank, Focus, Columns, Rows, Grid, PriorityGrid
|
||||
const int InitialTemplateCount = 6; // Blank, Focus, Columns, Rows, Grid, PriorityGrid
|
||||
|
||||
// Delete Focus template layout via context menu
|
||||
FancyZonesEditorHelper.ClickContextMenuItem(Session, deletedLayoutName, FancyZonesEditorHelper.ElementName.Delete);
|
||||
@@ -381,7 +382,7 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
// check the template layouts file
|
||||
var layoutTemplates = new LayoutTemplates();
|
||||
var data = layoutTemplates.Read(layoutTemplates.File);
|
||||
Assert.AreEqual(initialTemplateCount - 1, data.LayoutTemplates.Count);
|
||||
Assert.AreEqual(InitialTemplateCount - 1, data.LayoutTemplates.Count);
|
||||
Assert.IsFalse(data.LayoutTemplates.Exists(x => x.Type == LayoutType.Focus.TypeToString()));
|
||||
}
|
||||
|
||||
@@ -391,12 +392,12 @@ namespace Microsoft.FancyZonesEditor.UITests
|
||||
{
|
||||
var blankLayoutName = TestConstants.TemplateLayoutNames[LayoutType.Blank];
|
||||
|
||||
// Try to open context menu on Blank template - should not have delete option
|
||||
// Try to open edit dialog on Blank template - should not have delete option
|
||||
Session.Find<Element>(blankLayoutName).Find<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.EditLayoutButton)).Click();
|
||||
|
||||
// Verify delete button is not visible for Blank layout
|
||||
var deleteButtons = Session.FindAll<Button>(PowerToys.UITest.By.AccessibilityId(AccessibilityId.DeleteLayoutButton));
|
||||
Assert.IsTrue(deleteButtons.Count == 0 || !deleteButtons[0].Displayed);
|
||||
Assert.IsTrue(deleteButtons.Count == 0 || deleteButtons.All(b => !b.Displayed));
|
||||
|
||||
Session.Find<Button>(ElementName.Cancel).Click();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user