forked from Taritsyn/JavaScriptEngineSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntlTestsBase.cs
More file actions
33 lines (28 loc) · 717 Bytes
/
IntlTestsBase.cs
File metadata and controls
33 lines (28 loc) · 717 Bytes
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
using Xunit;
namespace JavaScriptEngineSwitcher.Tests
{
public abstract class IntlTestsBase : TestsBase
{
[Fact]
public virtual void SupportsDateTimeFormatConstructor()
{
// Arrange
const string functionCode = @"function formatDate(value, locale) {
if (typeof value === 'string' && value.length > 0) {
value = new Date(value);
}
return new Intl.DateTimeFormat(locale).format(value);
}";
const string targetOutput = "16.09.2021";
// Act
string output;
using (var jsEngine = CreateJsEngine())
{
jsEngine.Execute(functionCode);
output = jsEngine.CallFunction<string>("formatDate", "2021-09-16", "ru-ru");
}
// Assert
Assert.Equal(targetOutput, output);
}
}
}