Skip to content

Commit d493ed9

Browse files
committed
Updates coordinate assertion method
Uses IsCloseTo method for asserting coordinate proximity in UI tests for ComboBoxes, DatePickers, PasswordBoxes, and TextBoxes. This improves the accuracy and reliability of the tests by checking if the coordinates are within a specified tolerance range.
1 parent 8f537f1 commit d493ed9

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

tests/MaterialDesignThemes.UITests/WPF/ComboBoxes/ComboBoxTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,8 @@ public async Task ComboBox_WithHintAndHelperText_RespectsPadding(string styleNam
198198
Rect? hintCoordinates = await hint.GetCoordinates();
199199
Rect? helperTextCoordinates = await helperText.GetCoordinates();
200200

201-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsBetween(-tolerance, tolerance);
202-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsBetween(-tolerance, tolerance);
201+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsCloseTo(0, tolerance);
202+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsCloseTo(0, tolerance);
203203

204204
recorder.Success();
205205
}
@@ -247,8 +247,8 @@ public async Task ComboBox_WithHintAndValidationError_RespectsPadding(string sty
247247
Rect? hintCoordinates = await hint.GetCoordinates();
248248
Rect? errorViewerCoordinates = await errorViewer.GetCoordinates();
249249

250-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsBetween(-tolerance, tolerance);
251-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsBetween(-tolerance, tolerance);
250+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsCloseTo(0, tolerance);
251+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsCloseTo(0, tolerance);
252252

253253
recorder.Success();
254254
}

tests/MaterialDesignThemes.UITests/WPF/DatePickers/DatePickerTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,8 @@ public async Task DatePicker_WithHintAndHelperText_RespectsPadding(string styleN
176176
Rect? hintCoordinates = await hint.GetCoordinates();
177177
Rect? helperTextCoordinates = await helperText.GetCoordinates();
178178

179-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsBetween(0, tolerance);
180-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsBetween(0, tolerance);
179+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsCloseTo(0, tolerance);
180+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsCloseTo(0, tolerance);
181181

182182
recorder.Success();
183183
}
@@ -225,8 +225,8 @@ public async Task DatePicker_WithHintAndValidationError_RespectsPadding(string s
225225
Rect? hintCoordinates = await hint.GetCoordinates();
226226
Rect? errorViewerCoordinates = await errorViewer.GetCoordinates();
227227

228-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsBetween(0, tolerance);
229-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsBetween(0, tolerance);
228+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsCloseTo(0, tolerance);
229+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsCloseTo(0, tolerance);
230230

231231
recorder.Success();
232232
}

tests/MaterialDesignThemes.UITests/WPF/PasswordBoxes/PasswordBoxTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ public async Task PasswordBox_WithHintAndHelperText_RespectsPadding(string style
230230
Rect? helperTextCoordinates = await helperText.GetCoordinates();
231231

232232
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left))
233-
.IsBetween(0, tolerance);
233+
.IsCloseTo(0, tolerance);
234234
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left))
235-
.IsBetween(0, tolerance);
235+
.IsCloseTo(0, tolerance);
236236

237237
recorder.Success();
238238
}
@@ -290,9 +290,9 @@ public async Task PasswordBox_WithHintAndValidationError_RespectsPadding(string
290290
Rect? errorViewerCoordinates = await errorViewer.GetCoordinates();
291291

292292
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left))
293-
.IsBetween(0, tolerance);
293+
.IsCloseTo(0, tolerance);
294294
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left))
295-
.IsBetween(0, tolerance);
295+
.IsCloseTo(0, tolerance);
296296

297297
recorder.Success();
298298
}

tests/MaterialDesignThemes.UITests/WPF/TextBoxes/TextBoxTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,8 @@ public async Task TextBox_WithHintAndHelperText_RespectsPadding(string styleName
481481
Rect? hintCoordinates = await hint.GetCoordinates();
482482
Rect? helperTextCoordinates = await helperText.GetCoordinates();
483483

484-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsBetween(0, tolerance);
485-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsBetween(0, tolerance);
484+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsCloseTo(0, tolerance);
485+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - helperTextCoordinates.Value.Left)).IsCloseTo(0, tolerance);
486486

487487
recorder.Success();
488488
}
@@ -530,8 +530,8 @@ public async Task TextBox_WithHintAndValidationError_RespectsPadding(string styl
530530
Rect? hintCoordinates = await hint.GetCoordinates();
531531
Rect? errorViewerCoordinates = await errorViewer.GetCoordinates();
532532

533-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsBetween(0, tolerance);
534-
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsBetween(0, tolerance);
533+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - hintCoordinates.Value.Left)).IsCloseTo(0, tolerance);
534+
await Assert.That(Math.Abs(contentHostCoordinates.Value.Left - errorViewerCoordinates.Value.Left)).IsCloseTo(0, tolerance);
535535

536536
recorder.Success();
537537
}

0 commit comments

Comments
 (0)