mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 02:06:36 +02:00
* [Analyzers][AdvancedPaste] Apply fix for SA1516 * [Analyzers][EnvironmentVariables] Apply fix for SA1516 * [Analyzers][RegistryPreview] Apply fix for SA1516 * [Analyzers][Peek] Apply fix for SA1516 * [Analyzers][PreviewPane] Apply fix for SA1516 * [Analyzers][FancyZones] Apply fix for SA1516 * [Analyzers][PT Run][Plugins] Apply fix for SA1516 * [Analyzers][PT Run] Apply fix for SA1516 * [Analyzers][PT Run][Wox] Apply fix for SA1516 * [Analyzers][Common] Apply fix for SA1516 * [Analyzers][ImageResizer] Apply fix for SA1516 * [Analyzers][ColorPicker] Apply fix for SA1516 * [Analyzers][MouseUtils] Apply fix for SA1516 * [Analyzers][DSC Schema Generator] Apply fix for SA1516 * [Analyzers][FileLocksmith] Apply fix for SA1516 * [Analyzers][Hosts] Apply fix for SA1516 * [Analyzers][MeasureTool] Apply fix for SA1516 * [Analyzers][MouseWithoutBorders] Apply fix for SA1516 * [Analyzers][TextExtractor] Apply fix for SA1516 * [Analyzers][Workspaces] Apply fix for SA1516 * [Analyzers][Awake] Apply fix for SA1516 * [Analyzers][PowerAccent] Apply fix for SA1516 * [Analyzers][RegistryPreview] Apply fix for SA1516 * [Analyzers][Settings] Apply fix for SA1516 * [Analyzers][MouseWithoutBorders] Apply fix for SA1616
67 lines
2.2 KiB
C#
67 lines
2.2 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Globalization;
|
|
|
|
using Microsoft.PowerToys.Run.Plugin.TimeDate.Components;
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
|
|
{
|
|
[TestClass]
|
|
public class TimeAndDateHelperTests
|
|
{
|
|
[DataTestMethod]
|
|
[DataRow(-1, null)] // default setting
|
|
[DataRow(0, CalendarWeekRule.FirstDay)]
|
|
[DataRow(1, CalendarWeekRule.FirstFullWeek)]
|
|
[DataRow(2, CalendarWeekRule.FirstFourDayWeek)]
|
|
[DataRow(30, null)] // wrong setting
|
|
public void GetCalendarWeekRuleBasedOnPluginSetting(int setting, CalendarWeekRule? valueExpected)
|
|
{
|
|
// Act
|
|
var result = TimeAndDateHelper.GetCalendarWeekRule(setting);
|
|
|
|
// Assert
|
|
if (valueExpected == null)
|
|
{
|
|
// falls back to system setting.
|
|
Assert.AreEqual(DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, result);
|
|
}
|
|
else
|
|
{
|
|
Assert.AreEqual(valueExpected, result);
|
|
}
|
|
}
|
|
|
|
[DataTestMethod]
|
|
[DataRow(-1, null)] // default setting
|
|
[DataRow(1, DayOfWeek.Monday)]
|
|
[DataRow(2, DayOfWeek.Tuesday)]
|
|
[DataRow(3, DayOfWeek.Wednesday)]
|
|
[DataRow(4, DayOfWeek.Thursday)]
|
|
[DataRow(5, DayOfWeek.Friday)]
|
|
[DataRow(6, DayOfWeek.Saturday)]
|
|
[DataRow(0, DayOfWeek.Sunday)]
|
|
[DataRow(70, null)] // wrong setting
|
|
public void GetFirstDayOfWeekBasedOnPluginSetting(int setting, DayOfWeek? valueExpected)
|
|
{
|
|
// Act
|
|
var result = TimeAndDateHelper.GetFirstDayOfWeek(setting);
|
|
|
|
// Assert
|
|
if (valueExpected == null)
|
|
{
|
|
// falls back to system setting.
|
|
Assert.AreEqual(DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek, result);
|
|
}
|
|
else
|
|
{
|
|
Assert.AreEqual(valueExpected, result);
|
|
}
|
|
}
|
|
}
|
|
}
|