-
-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathTableViewTimeColumnTests.cs
More file actions
69 lines (59 loc) · 2.77 KB
/
Copy pathTableViewTimeColumnTests.cs
File metadata and controls
69 lines (59 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Data;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
using System;
using Windows.System.UserProfile;
using WinUI.TableView.Controls;
using WinUI.TableView.Helpers;
namespace WinUI.TableView.Tests;
[TestClass]
public class TableViewTimeColumnTests
{
[UITestMethod]
public void TableViewTimeColumn_GeneratesEditingElementWithConfiguredProperties()
{
var item = new ColumnTestItem { AppointmentTime = new TimeOnly(9, 30) };
var column = new TableViewTimeColumn
{
Binding = new Binding { Path = new PropertyPath(nameof(ColumnTestItem.AppointmentTime)) },
ClockIdentifier = "24HourClock",
MinuteIncrement = 15
};
var element = (TableViewTimePicker)column.GenerateEditingElement(new TableViewCell(), item);
var cell = new TableViewCell { Content = element };
element.SelectedTime = item.AppointmentTime;
Assert.AreEqual("24HourClock", element.ClockIdentifier);
Assert.AreEqual(15, element.MinuteIncrement);
Assert.AreEqual(TableViewLocalizedStrings.TimePickerPlaceholder, element.PlaceholderText);
Assert.AreEqual(typeof(TimeOnly), element.SourceType);
Assert.AreEqual(item.AppointmentTime, column.PrepareCellForEdit(cell, new RoutedEventArgs()));
var clocks = GlobalizationPreferences.Clocks;
Assert.AreEqual(clocks.Count > 0 ? clocks[0] : "24HourClock", new TableViewTimeColumn().ClockIdentifier);
}
[UITestMethod]
public void TableViewTimeColumn_GeneratesDisplayElement_WithFormatBindings()
{
var column = new TableViewTimeColumn
{
Binding = new Binding { Path = new PropertyPath(nameof(ColumnTestItem.AppointmentTime)) }
};
var element = (TextBlock)column.GenerateElement(new TableViewCell(), new ColumnTestItem());
Assert.IsNotNull(element.GetBindingExpression(DateTimeFormatHelper.ValueProperty));
Assert.IsNotNull(element.GetBindingExpression(DateTimeFormatHelper.FormatProperty));
Assert.AreEqual(new Thickness(12, 0, 12, 0), element.Margin);
}
[UITestMethod]
public void TableViewTimeColumn_UsesCustomPlaceholderAndTimeSpanFallback()
{
var column = new TableViewTimeColumn
{
Binding = new Binding { Path = new PropertyPath(nameof(ColumnTestItem.UnknownTimeLikeValue)) },
PlaceholderText = "Pick a time"
};
var element = (TableViewTimePicker)column.GenerateEditingElement(new TableViewCell(), new ColumnTestItem());
Assert.AreEqual("Pick a time", element.PlaceholderText);
Assert.AreEqual(typeof(TimeSpan), element.SourceType);
}
}