Exemplo n.º 1
0
 [Test] public void TestImplicitExpr()
 {
     Assert.AreEqual(LongV.Of(10), (Expr)10);
     Assert.AreEqual(LongV.Of(10), (Expr)10L);
     Assert.AreEqual(BooleanV.True, (Expr)true);
     Assert.AreEqual(BooleanV.False, (Expr)false);
     Assert.AreEqual(DoubleV.Of(3.14), (Expr)3.14);
     Assert.AreEqual(StringV.Of("a string"), (Expr)"a string");
     Assert.AreEqual(StringV.Of("create"), (Expr)ActionType.Create);
     Assert.AreEqual(StringV.Of("delete"), (Expr)ActionType.Delete);
     Assert.AreEqual(StringV.Of("second"), (Expr)TimeUnit.Second);
     Assert.AreEqual(StringV.Of("millisecond"), (Expr)TimeUnit.Millisecond);
     Assert.AreEqual(StringV.Of("microsecond"), (Expr)TimeUnit.Microsecond);
     Assert.AreEqual(StringV.Of("nanosecond"), (Expr)TimeUnit.Nanosecond);
     Assert.AreEqual(DateV.Of("2000-01-01"), (Expr) new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc));
     Assert.AreEqual(DateV.Of("2000-01-01"), (Expr) new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero));
     Assert.AreEqual(TimeV.Of("2000-01-01T01:01:01.123Z"), (Expr) new DateTime(2000, 1, 1, 1, 1, 1, 123, DateTimeKind.Utc));
     Assert.AreEqual(TimeV.Of("2000-01-01T01:01:01.123Z"), (Expr) new DateTimeOffset(2000, 1, 1, 1, 1, 1, 123, TimeSpan.Zero));
     Assert.AreEqual(NullV.Instance, (Expr)(string)null);
     Assert.AreEqual(
         ObjectV.With("name", "foo", "count", 42),
         (Expr) new Dictionary <string, Expr>()
     {
         { "name", "foo" }, { "count", 42 }
     });
     Assert.AreEqual(BytesV.Of(1, 2, 3), (Expr) new byte[] { 1, 2, 3 });
 }
Exemplo n.º 2
0
 public void TestImplicitValue()
 {
     Assert.AreEqual(LongV.Of(10), (Value)10);
     Assert.AreEqual(LongV.Of(10), (Value)10L);
     Assert.AreEqual(BooleanV.True, (Value)true);
     Assert.AreEqual(BooleanV.False, (Value)false);
     Assert.AreEqual(DoubleV.Of(3.14), (Value)3.14);
     Assert.AreEqual(StringV.Of("a string"), (Value)"a string");
     Assert.AreEqual(StringV.Of("create"), (Value)ActionType.Create);
     Assert.AreEqual(StringV.Of("delete"), (Value)ActionType.Delete);
     Assert.AreEqual(StringV.Of("second"), (Value)TimeUnit.Second);
     Assert.AreEqual(StringV.Of("millisecond"), (Value)TimeUnit.Millisecond);
     Assert.AreEqual(StringV.Of("microsecond"), (Value)TimeUnit.Microsecond);
     Assert.AreEqual(StringV.Of("nanosecond"), (Value)TimeUnit.Nanosecond);
     Assert.AreEqual(DateV.Of("2000-01-01"), (Value) new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Utc));
     Assert.AreEqual(DateV.Of("2000-01-01"), (Value) new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero));
     Assert.AreEqual(TimeV.Of("2000-01-01T01:01:01.123Z"), (Value) new DateTime(2000, 1, 1, 1, 1, 1, 123, DateTimeKind.Utc));
     Assert.AreEqual(TimeV.Of("2000-01-01T01:01:01.123Z"), (Value) new DateTimeOffset(2000, 1, 1, 1, 1, 1, 123, TimeSpan.Zero));
     Assert.AreEqual(NullV.Instance, (Value)(string)null);
     Assert.AreEqual(BytesV.Of(1, 2, 3), (Value) new byte[] { 1, 2, 3 });
 }
Exemplo n.º 3
0
 /// <summary>
 /// Creates a new Bytes value
 /// </summary>
 public static Expr Bytes(params byte[] bytes) =>
 BytesV.Of(bytes);