Пример #1
0
        public void TestDateTimeOffsetConstant()
        {
            var constant = new EdmDateTimeOffsetConstant(DateTimeOffset.MinValue);
            Assert.AreEqual(EdmValueKind.DateTimeOffset, constant.ValueKind, "Invalid value kind.");

            this.ValidateEdmValueKindRoundTrip(EdmValueKind.DateTimeOffset, EdmCoreModel.Instance.GetDateTimeOffset(true), constant);
        }
        public void EdmDateTimeOffsetConstant()
        {
            var e = new EdmDateTimeOffsetConstant(new DateTimeOffset(2011, 9, 8, 0, 0, 0, new TimeSpan(1, 2, 0)));
            Assert.AreEqual(EdmExpressionKind.DateTimeOffsetConstant, e.ExpressionKind, "e.ExpressionKind");
            Assert.IsNull(e.Type, "e.Type");
            Assert.AreEqual(new DateTimeOffset(2011, 9, 8, 0, 0, 0, new TimeSpan(1, 2, 0)), e.Value, "e.Value");

            e = new EdmDateTimeOffsetConstant(EdmCoreModel.Instance.GetDateTimeOffset(true), new DateTimeOffset(2211, 9, 8, 0, 0, 0, new TimeSpan(1, 2, 0)));
            Assert.AreEqual(true, e.Type.IsNullable, "e.Type.IsNullable");
            Assert.AreEqual(new DateTimeOffset(2211, 9, 8, 0, 0, 0, new TimeSpan(1, 2, 0)), e.Value, "e.Value");

            e = new EdmDateTimeOffsetConstant(null, new DateTimeOffset(2011, 9, 8, 0, 0, 0, new TimeSpan(1, 2, 0)));
            Assert.IsNull(e.Type, "e.Type");

            Assert.IsFalse(e.IsBad(), "Expression not bad.");
            Assert.AreEqual(0, e.Errors().Count(), "Expression has no errors");
        }