-
-
Notifications
You must be signed in to change notification settings - Fork 567
/
Copy pathUuidTests.cs
50 lines (43 loc) · 1.26 KB
/
UuidTests.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
using Jint.Tests.Runtime.Domain;
using System;
using Xunit;
namespace Jint.Tests.Runtime
{
public class UuidTests : IDisposable
{
private readonly Engine _engine;
public UuidTests()
{
_engine = new Engine(o => o.AddObjectConverter(new UuidConverter()))
.SetValue("copy", new Func<Guid, Guid>(v => new Guid(v.ToByteArray())))
;
UuidConstructor.CreateUuidConstructor(_engine);
}
void IDisposable.Dispose()
{
}
private object RunTest(string source)
{
return _engine.Execute(source).GetCompletionValue().ToObject();
}
[Fact]
public void Empty()
{
Assert.Equal(Guid.Empty, RunTest($"Uuid.parse('{Guid.Empty}')"));
Assert.Equal(Guid.Empty, RunTest($"Uuid.Empty"));
}
[Fact]
public void Random()
{
var actual = RunTest($"new Uuid()");
Assert.NotEqual(Guid.Empty, actual);
Assert.IsType<Guid>(actual);
}
[Fact]
public void Copy()
{
var actual = (bool)RunTest($"const g = new Uuid(); copy(g).toString() === g.toString()");
Assert.True(actual);
}
}
}