Repository: microsoft/PowerToys
File: src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests/TimeDateResultTests.cs (C#)

Code before:
using System.Globalization;
using System.Linq;
using Microsoft.PowerToys.Run.Plugin.TimeDate.Components;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
{
    [TestClass]
    public class TimeDateResultTests
    {
        private CultureInfo originalCulture;
        private CultureInfo originalUiCulture;

        [TestInitialize]
        public void Setup()
        {
            // Set culture to 'en-us'
            originalCulture = CultureInfo.CurrentCulture;
            CultureInfo.CurrentCulture = new CultureInfo("en-us");
            originalUiCulture = CultureInfo.CurrentUICulture;
            CultureInfo.CurrentUICulture = new CultureInfo("en-us");
        }

        [DataTestMethod]
        [DataRow("time", "10:30 AM")]
        [DataRow("date", "3/2/2022")]
        [DataRow("date and time", "3/2/2022 10:30 AM")]
        [DataRow("hour", "10")]
        [DataRow("minute", "30")]
        [DataRow("second", "45")]
        [DataRow("millisecond", "0")]
        [DataRow("day (week day)", "Wednesday")]
        [DataRow("day of the week (week day)", "4")]
        [DataRow("day of the month", "2")]
        [DataRow("day of the year", "61")]
        [DataRow("week of the month", "1")]
        [DataRow("week of the year (calendar week, week number)", "10")]
        [DataRow("month", "March")]
        [DataRow("month of the year", "3")]
        [DataRow("month and day", "March 2")]
        [DataRow("year", "2022")]
        [DataRow("month and year", "March 2022")]
        [DataRow("ISO 8601", "2022-03-02T10:30:45")]
        [DataRow("ISO 8601 with time zone", "2022-03-02T10:30:45")]
        [DataRow("RFC1123", "Wed, 02 Mar 2022 10:30:45 GMT")]
        public void LocalFormatsWithShortTimeAndShortDate(string formatLabel, string expectedResult)
        {
            // Setup
            var helperResults = AvailableResultsList.GetList(true, false, false, new DateTime(2022, 03, 02, 10, 30, 45));

            // Act

Review comment (suggestion):
I converted all the tests hours from 10AM to 10PM, since I think it is better to test with hour whose formatting changes depending on 24h/12h AM-PM formatting preference.

Code after:
using System.Globalization;
using System.Linq;
using Microsoft.PowerToys.Run.Plugin.TimeDate.Components;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Microsoft.PowerToys.Run.Plugin.TimeDate.UnitTests
{
    [TestClass]
    public class TimeDateResultTests
    {
        private CultureInfo originalCulture;
        private CultureInfo originalUiCulture;

        [TestInitialize]
        public void Setup()
        {
            // Set culture to 'en-us'
            originalCulture = CultureInfo.CurrentCulture;
            CultureInfo.CurrentCulture = new CultureInfo("en-us");
            originalUiCulture = CultureInfo.CurrentUICulture;
            CultureInfo.CurrentUICulture = new CultureInfo("en-us");
        }

        private DateTime GetDateTimeForTest()
        {
            return new DateTime(2022, 03, 02, 22, 30, 45);
        }

        [DataTestMethod]
        [DataRow("time", "10:30 PM")]
        [DataRow("date", "3/2/2022")]
        [DataRow("date and time", "3/2/2022 10:30 PM")]
        [DataRow("hour", "22")]
        [DataRow("minute", "30")]
        [DataRow("second", "45")]
        [DataRow("millisecond", "0")]
        [DataRow("day (week day)", "Wednesday")]
        [DataRow("day of the week (week day)", "4")]
        [DataRow("day of the month", "2")]
        [DataRow("day of the year", "61")]
        [DataRow("week of the month", "1")]
        [DataRow("week of the year (calendar week, week number)", "10")]
        [DataRow("month", "March")]
        [DataRow("month of the year", "3")]
        [DataRow("month and day", "March 2")]
        [DataRow("year", "2022")]
        [DataRow("month and year", "March 2022")]
        [DataRow("ISO 8601", "2022-03-02T22:30:45")]
        [DataRow("ISO 8601 with time zone", "2022-03-02T22:30:45")]
        [DataRow("RFC1123", "Wed, 02 Mar 2022 22:30:45 GMT")]
        [DataRow("Date and time in filename-compatible format", "2022-03-02_22-30-45")]