Exemple #1
0
        public void TestCreateObjectSystem()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos     = new DynamicObjectSystem(ConnectionString, storeId);

            Assert.IsNotNull(dos);
        }
Exemple #2
0
        public void TestNoTypesExist()
        {
            var storeId   = Guid.NewGuid().ToString();
            var dos       = new DynamicObjectSystem(ConnectionString, storeId);
            var typeCount = dos.Types.Count();

            Assert.AreEqual(0, typeCount);
        }
        public void TestCreateTypedDynamicObject()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos = new DynamicObjectSystem(ConnectionString, storeId);
            var person = dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var bob = dos.CreateNewDynamicObject("Person");

            // check that the id of the type of the instance is the same as the type we passed in.
            Assert.AreEqual(person.Identity, bob.ds__type[0].Identity);
        }
Exemple #4
0
        public void TestCreateTypedDynamicObject()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos     = new DynamicObjectSystem(ConnectionString, storeId);
            var person  = dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var bob     = dos.CreateNewDynamicObject("Person");

            // check that the id of the type of the instance is the same as the type we passed in.
            Assert.AreEqual(person.Identity, bob.ds__type[0].Identity);
        }
        public void TestAssertType()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos = new DynamicObjectSystem(ConnectionString, storeId);
            var typeCount = dos.Types.Count();
            Assert.AreEqual(0, typeCount);

            dos.AssertType("Person", new string[] { "age", "name", "hometown" });

            typeCount = dos.Types.Count();
            Assert.AreEqual(1, typeCount);
        }
Exemple #6
0
        public void TestGetType()
        {
            var storeId   = Guid.NewGuid().ToString();
            var dos       = new DynamicObjectSystem(ConnectionString, storeId);
            var typeCount = dos.Types.Count();

            Assert.AreEqual(0, typeCount);
            dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var type = dos.GetType("Person");

            Assert.IsNotNull(type);
        }
Exemple #7
0
        public void TestGetInstancesOfType()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos     = new DynamicObjectSystem(ConnectionString, storeId);
            var person  = dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var bob     = dos.CreateNewDynamicObject("Person");

            dos.SaveChanges();

            var instancesOfPerson = dos.GetInstancesOfType("Person");

            Assert.AreEqual(1, instancesOfPerson.Count());
        }
        public void TestEnumerateTypeAllowedProperties()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos = new DynamicObjectSystem(ConnectionString, storeId);
            var typeCount = dos.Types.Count();
            Assert.AreEqual(0, typeCount);
            dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var type = dos.GetType("Person");

            var properties = type.ds__properties as IEnumerable<object>;
            Assert.AreEqual(3, properties.ToList().Count());

            Assert.IsTrue(properties.Contains("age"));
            Assert.IsTrue(properties.Contains("name"));
            Assert.IsTrue(properties.Contains("hometown"));
        }
Exemple #9
0
        public void TestFindByQuery()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos     = new DynamicObjectSystem(ConnectionString, storeId);
            var person  = dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var bob     = dos.CreateNewDynamicObject("Person");

            bob.ds__name = "Bob";
            var bill = dos.CreateNewDynamicObject("Person");

            bill.ds__name = "Bill";
            dos.SaveChanges();

            var queryResult = dos.FindByQuery("select ?id where { ?id <" + DynamicObjectSystem.UriPrefix + "name> \"Bob\"^^<http://www.w3.org/2001/XMLSchema#string> }");

            Assert.AreEqual(1, queryResult.Count());
        }
Exemple #10
0
        public void TestEnumerateTypeAllowedProperties()
        {
            var storeId   = Guid.NewGuid().ToString();
            var dos       = new DynamicObjectSystem(ConnectionString, storeId);
            var typeCount = dos.Types.Count();

            Assert.AreEqual(0, typeCount);
            dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var type = dos.GetType("Person");

            var properties = type.ds__properties as IEnumerable <object>;

            Assert.AreEqual(3, properties.ToList().Count());

            Assert.IsTrue(properties.Contains("age"));
            Assert.IsTrue(properties.Contains("name"));
            Assert.IsTrue(properties.Contains("hometown"));
        }
        public void TestDeleteObject()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos = new DynamicObjectSystem(ConnectionString, storeId);
            var person = dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var bob = dos.CreateNewDynamicObject("Person");
            dos.SaveChanges();

            var instancesOfPerson = dos.GetInstancesOfType("Person");
            Assert.AreEqual(1, instancesOfPerson.Count());

            // delete object
            dos.DeleteObject(bob.Identity);
            dos.SaveChanges();

            // check bob is gone
            instancesOfPerson = dos.GetInstancesOfType("Person");
            Assert.AreEqual(0, instancesOfPerson.Count());
        }
        public void TestFindByQuery()
        {
            var storeId = Guid.NewGuid().ToString();
            var dos = new DynamicObjectSystem(ConnectionString, storeId);
            var person = dos.AssertType("Person", new string[] { "age", "name", "hometown" });
            var bob = dos.CreateNewDynamicObject("Person");
            bob.ds__name = "Bob";
            var bill = dos.CreateNewDynamicObject("Person");
            bill.ds__name = "Bill";
            dos.SaveChanges();

            var queryResult = dos.FindByQuery("select ?id where { ?id <" + DynamicObjectSystem.UriPrefix + "name> \"Bob\"^^<http://www.w3.org/2001/XMLSchema#string> }" );
            Assert.AreEqual(1, queryResult.Count());
        }
 public void TestCreateObjectSystem()
 {
     var storeId = Guid.NewGuid().ToString();
     var dos = new DynamicObjectSystem(ConnectionString, storeId);
     Assert.IsNotNull(dos);
 }
 public void TestNoTypesExist()
 {
     var storeId = Guid.NewGuid().ToString();
     var dos = new DynamicObjectSystem(ConnectionString, storeId);
     var typeCount = dos.Types.Count();
     Assert.AreEqual(0, typeCount);
 }