public void TestNullableDateTime()
        {
            var clazz = new Class_NullableDateTime {
                Attr = (NullableDateTime)DateTime.Now
            };

            DataService.UpdateObject(clazz);
            var clazz2 = new Class_NullableDateTime {
                __PrimaryKey = clazz.__PrimaryKey
            };

            DataService.LoadObject(clazz2);
            Assert.True(clazz.Attr.Value.ToString("d MMM yyyy HH:mm:ss.fff") == clazz2.Attr.Value.ToString("d MMM yyyy HH:mm:ss.fff"));
            clazz2.Attr = (NullableDateTime)clazz2.Attr.Value.AddMonths(1);
            DataService.UpdateObject(clazz2);
            clazz2 = new Class_NullableDateTime {
                __PrimaryKey = clazz.__PrimaryKey
            };
            DataService.LoadObject(clazz2);
            Assert.True(clazz.Attr.Value.ToString("d MMM yyyy HH:mm:ss.fff") != clazz2.Attr.Value.ToString("d MMM yyyy HH:mm:ss.fff"));
            clazz2.SetStatus(ObjectStatus.Deleted);
            DataService.UpdateObject(clazz2);
            clazz2 = new Class_NullableDateTime {
                __PrimaryKey = clazz.__PrimaryKey
            };
            try
            {
                DataService.LoadObject(clazz2);
                Assert.True(false, "Object not deleted.");
            }
            catch (CantFindDataObjectException)
            {
            }
        }
コード例 #2
0
        public void NullableDateTimeSerialization()
        {
            // Arrange.
            STORMNET.DataObject nullDateTime = new Class_NullableDateTime()
            {
                Attr = null
            };
            STORMNET.DataObject deserializedObject = new Class_NullableDateTime();

            // Act.
            var serializedObj = ToolXML.DataObject2XMLDocument(ref nullDateTime);

            ToolXML.XMLDocument2DataObject(ref deserializedObject, serializedObj);

            // Assert.
            Assert.Equal(((Class_NullableDateTime)nullDateTime).Attr, ((Class_NullableDateTime)deserializedObject).Attr);
        }