Example #1
0
        public void NullWebFileSerialization()
        {
            // Сейчас объект не десериализуется.

            // Arrange.
            STORMNET.DataObject nullWebFile = new Class_WebFile()
            {
                Attr = null
            };
            STORMNET.DataObject deserializedObject = new Class_WebFile();

            var serializedObj = ToolXML.DataObject2XMLDocument(ref nullWebFile);

            // Act.
            ToolXML.XMLDocument2DataObject(ref deserializedObject, serializedObj);
        }
        public void TestWebFile()
        {
            var clazz = new Class_WebFile {
                Attr = new WebFile {
                    Name = "Test1"
                }
            };

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

            DataService.LoadObject(clazz2);
            Assert.True((string)clazz.Attr == (string)clazz2.Attr);
            clazz2.Attr = new WebFile {
                Name = "Test2"
            };
            DataService.UpdateObject(clazz2);
            clazz2 = new Class_WebFile {
                __PrimaryKey = clazz.__PrimaryKey
            };
            DataService.LoadObject(clazz2);
            Assert.True((string)clazz.Attr != (string)clazz2.Attr);
            clazz2.SetStatus(ObjectStatus.Deleted);
            DataService.UpdateObject(clazz2);
            clazz2 = new Class_WebFile {
                __PrimaryKey = clazz.__PrimaryKey
            };
            try
            {
                DataService.LoadObject(clazz2);
                Assert.True(false, "Object not deleted.");
            }
            catch (CantFindDataObjectException)
            {
            }
        }