Exemplo n.º 1
0
        public void ModelNameTest()
        {
            Uri    modelUri  = new Uri("http://www.example.com");
            Uri    modelUri2 = new Uri("http://www.example.com/");
            IModel m1        = Store.GetModel(modelUri);

            m1.Clear();
            IModel m2 = Store.GetModel(modelUri2);

            Assert.IsTrue(m1.IsEmpty);
            Assert.IsTrue(m2.IsEmpty);

            PersonContact c = m1.CreateResource <PersonContact>(new Uri("http://www.example.com/testResource"));

            c.NameFamily = "Doe";
            c.Commit();

            Assert.IsFalse(m1.IsEmpty);
            Assert.IsFalse(m2.IsEmpty);

            m1.Clear();

            Assert.IsTrue(m1.IsEmpty);
            Assert.IsTrue(m2.IsEmpty);
        }
Exemplo n.º 2
0
        Contact CreateContact(IModel m, string nameGiven, List <string> nameAdditional, string nameFamily, DateTime birthDate, string emailAddress, string country, string street, string pocode, string city)
        {
            Uri           contactUri = new Uri("semio:" + nameGiven + ":" + Guid.NewGuid().ToString());
            PersonContact c          = m.CreateResource <PersonContact>(contactUri);
            StringBuilder b          = new StringBuilder();

            foreach (string n in nameAdditional)
            {
                b.Append(n);
                b.Append(" ");
                c.NameAdditional.Add(n);
            }
            if (b.Length > 1)
            {
                b.Remove(b.Length - 1, 1);
            }
            c.Fullname   = string.Format("{0} {1} {2}", nameGiven, b, nameFamily);
            c.NameGiven  = nameGiven;
            c.NameFamily = nameFamily;
            c.BirthDate  = birthDate;
            c.EmailAddresses.Add(CreateEmailAddress(m, emailAddress));
            c.PostalAddresses.Add(CreatePostalAddress(m, country, street, pocode, city));

            c.Commit();
            return(c);
        }
Exemplo n.º 3
0
 public void TestAddMultipleResources()
 {
     Assert.Inconclusive("This test should work, it just takes too long.");
     Model.Clear();
     for (int j = 1; j < 7; j++)
     {
         for (int i = 1; i < 1000; i++)
         {
             using (PersonContact pers = Model.CreateResource <PersonContact>())
             {
                 pers.Fullname = string.Format("Name {0}", i * j);
                 pers.Commit();
             }
         }
     }
 }
Exemplo n.º 4
0
        public void GetTypedResourcesTest()
        {
            Uri     uriResource = new Uri("http://example.org/Peter");
            Contact contact     = Model.CreateResource <Contact>(uriResource);

            contact.Fullname = "Peter";
            contact.Commit();

            uriResource = new Uri("http://example.org/Hans");
            Contact contact2 = Model.CreateResource <Contact>(uriResource);

            contact2.Fullname = "Hans";
            contact2.Commit();

            var r = Model.GetResources <Contact>();

            Assert.AreEqual(2, r.Count());
            Assert.IsTrue(r.Contains(contact));
            Assert.IsTrue(r.Contains(contact2));

            Model.Clear();

            PersonContact personContact = Model.CreateResource <PersonContact>(uriResource);

            personContact.Fullname = "Peter";
            personContact.Commit();

            r = Model.GetResources <Contact>();
            Assert.AreEqual(0, r.Count());

            r = Model.GetResources <Contact>(true);
            Assert.AreEqual(1, r.Count());

            var x = Model.GetResource(uriResource);

            Assert.AreEqual(typeof(PersonContact), x.GetType());
        }