public virtual void TestValueField() {
            FileVersion.Clock = new TestClock();

            TestProxySpecification type = new TestProxySpecification(typeof (string));
            ObjectData objectData = new ObjectData(type, SerialOid.CreatePersistent(13, typeof(string).FullName), new FileVersion(""));

            Assert.AreEqual(null, objectData.Value("name"));
            objectData.SetField("name", "value");
            Assert.AreEqual("value", objectData.Value("name"));

            IEnumerator<string> e = objectData.Fields();
            Assert.IsTrue(e.MoveNext());
            Assert.IsNotNull(e.Current);
            Assert.IsFalse(e.MoveNext());
        }
        public virtual void TestValueField()
        {
            FileVersion.Clock = new TestClock();

            TestProxySpecification type       = new TestProxySpecification(typeof(string));
            ObjectData             objectData = new ObjectData(type, SerialOid.CreatePersistent(13, typeof(string).FullName), new FileVersion(""));

            Assert.AreEqual(null, objectData.Value("name"));
            objectData.SetField("name", "value");
            Assert.AreEqual("value", objectData.Value("name"));

            IEnumerator <string> e = objectData.Fields();

            Assert.IsTrue(e.MoveNext());
            Assert.IsNotNull(e.Current);
            Assert.IsFalse(e.MoveNext());
        }
Exemplo n.º 3
0
        public virtual void TestInsertObjectWithFields()
        {
            ObjectData data = CreateData(typeof(Role), 99, new FileVersion("user", 13));

            data.SetField("Person", SerialOid.CreatePersistent(101, typeof(Person).FullName));
            Assert.IsNotNull(data.GetField("Person"));
            data.SetField("Name", "Harry");
            Assert.IsNotNull(data.Value("Name"));

            manager.InsertObject(data);

            ObjectData read = manager.LoadObjectData(data.Oid);

            Assert.AreEqual(data.Oid, read.Oid);
            Assert.AreEqual(data.ClassName, read.ClassName);

            Assert.AreEqual(data.GetField("Person"), read.GetField("Person"));
            Assert.AreEqual(data.Value("Name"), read.Value("Name"));
        }
Exemplo n.º 4
0
        public virtual void TestSaveObject()
        {
            data[2].SetField("Person", SerialOid.CreatePersistent(231, typeof(Person).FullName));
            data[2].SetField("Name", "Fred");
            manager.Save(data[2]);

            Assert.IsTrue(Enumerable.Contains(manager.GetInstances(system.GetSpecification(typeof(object))), data[2]));
            ObjectData read = manager.LoadObjectData(oids[2]);

            Assert.AreEqual(data[2], read);
            Assert.AreEqual(data[2].Value("Name"), read.Value("Name"));
            Assert.AreEqual(data[2].GetField("Person"), read.GetField("Person"));
        }
Exemplo n.º 5
0
        private static void InitEncodeable(INakedObject nakedObject, ObjectData data, INakedObjectAssociation field, INakedObjectSpecification fieldSpecification)
        {
            INakedObject nakedObjectValue;
            string       valueData = data.Value(field.Id);

            if (valueData == null || valueData.Equals("NULL"))
            {
                nakedObjectValue = null;
            }
            else
            {
                nakedObjectValue = fieldSpecification.GetFacet <IEncodeableFacet>().FromEncodedString(valueData);
            }
            ((IOneToOneAssociation)field).InitAssociation(nakedObject, nakedObjectValue);
        }