public void LocalFormatsWithShortTimeAndLongDate(string formatLabel, string expectedResult) { // Setup var helperResults = AvailableResultsList.GetList(true, false, true, new DateTime(2022, 03, 02, 10, 30, 45)); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); // Assert Assert.AreEqual(expectedResult, result?.Value); }
public void LocalFormatsWithShortTimeAndShortDate(string formatLabel, string expectedResult) { // Setup var helperResults = AvailableResultsList.GetList(true, false, false, new DateTime(2022, 03, 02, 10, 30, 45)); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); // Assert Assert.AreEqual(expectedResult, result?.Value, $"Culture {CultureInfo.CurrentCulture.Name}, Culture UI: {CultureInfo.CurrentUICulture.Name}, Calendar: {CultureInfo.CurrentCulture.Calendar}, Region: {RegionInfo.CurrentRegion.Name}"); }
public void UtcFormatsWithLongTimeAndLongDate(string formatLabel, string expectedFormat) { // Setup var helperResults = AvailableResultsList.GetList(true, true, true, new DateTime(2022, 03, 02, 10, 30, 45)); var expectedResult = new DateTime(2022, 03, 02, 10, 30, 45).ToUniversalTime().ToString(expectedFormat, CultureInfo.CurrentCulture); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); // Assert Assert.AreEqual(expectedResult, result?.Value); }
public void ValidateEraAbbreviationResult() { // Setup string formatLabel = "Era abbreviation"; DateTime timeValue = DateTime.Now; var helperResults = AvailableResultsList.GetList(true, false, false, timeValue); var expectedResult = DateTimeFormatInfo.CurrentInfo.GetAbbreviatedEraName(CultureInfo.CurrentCulture.Calendar.GetEra(timeValue)); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); // Assert Assert.AreEqual(expectedResult, result?.Value); }
public void WindowsFileTimeFormat() { // Setup string formatLabel = "Windows file time (Int64 number)"; DateTime timeValue = DateTime.Now; var helperResults = AvailableResultsList.GetList(true, false, false, timeValue); var expectedResult = timeValue.Ticks.ToString(CultureInfo.CurrentCulture); // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); // Assert Assert.AreEqual(expectedResult, result?.Value); }
public void UnixTimestampFormat() { // Setup string formatLabel = "Unix epoch time"; DateTime timeValue = DateTime.Now.ToUniversalTime(); var helperResults = AvailableResultsList.GetList(true, false, false, timeValue); var expectedResult = (long)timeValue.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; // Act var result = helperResults.FirstOrDefault(x => x.Label.Equals(formatLabel, StringComparison.OrdinalIgnoreCase)); // Assert Assert.AreEqual(expectedResult.ToString(CultureInfo.CurrentCulture), result?.Value); }