-
Notifications
You must be signed in to change notification settings - Fork 369
/
Copy pathDateTimeExtensionsTests.cs
52 lines (45 loc) · 1.69 KB
/
DateTimeExtensionsTests.cs
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
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using MultiMiner.UX.Extensions;
using System.Globalization;
using System.Threading;
namespace MultiMiner.UX.Tests
{
[TestClass]
public class DateTimeExtensionsTests
{
[TestMethod]
public void ToReallyShortDateString_CurrentCulture_Works()
{
//arrange
DateTime now = DateTime.Now;
string shortDateString = now.ToShortDateString();
string dateSeparator = CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator;
string value1 = now.Year + dateSeparator;
string value2 = dateSeparator + now.Year;
string expectedValue = shortDateString.Replace(value1, String.Empty).Replace(value2, String.Empty);
//act
string reallyShortDateString = now.ToReallyShortDateString();
//assert
Assert.AreEqual(reallyShortDateString, expectedValue);
}
[TestMethod]
public void ToReallyShortDateString_RussianCulture_Works()
{
//arrange
Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ru-RU");
//act & assert
ToReallyShortDateString_CurrentCulture_Works();
}
[TestMethod]
public void ToReallyShortDateString_JapaneseCulture_Works()
{
//arrange
Thread.CurrentThread.CurrentCulture = new CultureInfo("ja-JP");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("ja-JP");
//act & assert
ToReallyShortDateString_CurrentCulture_Works();
}
}
}