public void Create_Creates_List_With_Custom_Nullable_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <NullableItem> list = null;
                try
                {
                    list = factory.Create <NullableItem>("Create_Creates_List_With_Custom_Nullable_Test");

                    list.ContainsField(i => i.CustomDouble);
                    list.ContainsField(i => i.CustomInt);
                    list.ContainsField(i => i.CustomDecimal);
                    list.ContainsField(i => i.CustomBoolean);
                    list.ContainsField(i => i.CustomDate);
                    list.ContainsField(i => i.CustomChoice);
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                }
            }
        }
예제 #2
0
        public void Ensure_Repository_By_Url_Test()
        {
            using (var app = TestAppEnsureLists.Factory.OpenNew(_webUrl))
            {
                IQueryList <OneMoreField <string> > list = null;
                try
                {
                    list = app.Ensure(a => a.EnsureRepositoryByUrl);

                    Assert.NotNull(list);
                    Assert.That(list.Title.ToLower(), Is.EqualTo("ensurerepositorybyurl"));
                    Assert.That(list.RelativeUrl.ToLower(), Is.EqualTo("lists/ensurerepurl"));

                    IQueryList <OneMoreField <string> > list2 = null;
                    Assert.DoesNotThrow(() =>
                    {
                        list2 = app.Ensure(a => a.EnsureRepositoryByUrl);
                    });

                    Assert.That(list.Id == list2.Id);
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                }
            }
        }
예제 #3
0
        public void AppBase_ApplicationRespository_Test()
        {
            using (var app = AppWithRepository.Factory.OpenNew(_webUrl))
            {
                IQueryList <OneMoreField <string> > queryList = null;
                try
                {
                    queryList = app.QueryWeb.Create <OneMoreField <string> >("CustomItems");

                    var ci = app.CustomItems;

                    var item = new OneMoreField <string>
                    {
                        Title           = "Test",
                        AdditionalField = "Test2",
                    };

                    ci.Add(item);
                }
                finally
                {
                    if (queryList != null)
                    {
                        queryList.DeleteList(false);
                    }
                }
            }
        }
예제 #4
0
 public void Dispose()
 {
     if (List != null)
     {
         List.DeleteList(false);
     }
     if (Web != null)
     {
         Web.Dispose();
     }
 }
        public void Create_Creates_List_With_Custom_Fields_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <Item> list1;
                try
                {
                    list1 = factory.Create <Item>("ListForLookup");
                }
                catch (SPException)
                {
                    list1 = factory.GetByName <Item>("ListForLookup");
                }
                IQueryList <CustomItem> list = null;
                try
                {
                    list = factory.Create <CustomItem>("List755");

                    Assert.AreEqual(list.Title, "List755");

                    Assert.That(list1.ContainsContentType <Item>());

                    Assert.That(list.ContainsField(ci => ci.CustomField1), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomField2), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomFieldNumber), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomBoolean), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomUser), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomUsers), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomLookup), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomMultiLookup), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomChoice), Is.True);
                    Assert.That(list.ContainsField(ci => ci.Тыдыщ), Is.True);

                    var choiceField = list.GetField(ci => ci.CustomChoice);
                    Assert.NotNull(choiceField.Choices);
                    Assert.That(choiceField.Choices.Count(), Is.EqualTo(3));
                    var choiceWithName = choiceField.Choices.Skip(1).First();
                    Assert.That(choiceWithName, Is.EqualTo("The Choice Number Two"));
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                    list1.DeleteList(false);
                }
            }
        }
예제 #6
0
        public void Upload_Rename_WithoutVersioning_Test()
        {
            IQueryList <Document> lib = null;

            try
            {
                lib = _queryWeb.Create <Document>("Upload_Rename_WithoutVersioning_Test");
                var document = new Document
                {
                    Name    = "Doc1.dat",
                    Content = new byte[] { 5, 10, 15, 25 },
                };
                lib.Add(document);

                var document2 = new Document
                {
                    Name           = "Doc1.dat",
                    Content        = new byte[] { 5, 10, 15, 27 },
                    RenameIfExists = true,
                };
                lib.Add(document2);

                var item = lib.Items(new CamlQuery()
                                     .Query(Q.Where(Q.Eq(Q.FieldRef <Document>(d => d.Name), Q.Value("Doc1.dat")))))
                           .FirstOrDefault();

                Assert.IsNotNull(item);
                Assert.That(item.Id, Is.EqualTo(document.Id));
                Assert.That(item.Name, Is.EqualTo(document.Name));
                Assert.That(item.Version.Major, Is.EqualTo(1));

                var item2 = lib.Items(new CamlQuery()
                                      .Query(Q.Where(Q.Eq(Q.FieldRef <Document>(d => d.Name), Q.Value("Doc1(1).dat")))))
                            .FirstOrDefault();

                Assert.IsNotNull(item2);
                Assert.That(item2.Id, Is.EqualTo(document2.Id));
                Assert.That(item2.Name, Is.EqualTo(document2.Name));
                Assert.That(item2.Version.Major, Is.EqualTo(1));
            }
            finally
            {
                if (lib != null)
                {
                    lib.DeleteList(false);
                }
            }
        }
        public void Create_Creates_DocLibrary_With_Custom_Fields_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <Item>           list1 = null;
                IQueryList <CustomDocument> list  = null;

                try
                {
                    try
                    {
                        list1 = factory.Create <Item>("ListForLookup");
                    }
                    catch (SPException)
                    {
                        list1 = factory.GetByName <Item>("ListForLookup");
                    }
                    list = factory.Create <CustomDocument>("List759");

                    Assert.AreEqual(list.Title, "List759");

                    Assert.That(list.ContainsContentType <Item>() == false);
                    Assert.That(list.ContainsContentType <Document>());

                    Assert.That(list.ContainsField(ci => ci.CustomField1), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomField2), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomFieldNumber), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomBoolean), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomUser), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomUsers), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomLookup), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomMultiLookup), Is.True);
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                    if (list1 != null)
                    {
                        list1.DeleteList(false);
                    }
                }
            }
        }
        public void Create_Creates_List_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <Item> list = null;
                try
                {
                    list = factory.Create <Item>("List754");
                    Assert.AreEqual(list.Title, "List754");

                    Assert.That(list.ContainsContentType <Item>());
                }
                finally
                {
                    if (null != list)
                    {
                        list.DeleteList(false);
                    }
                }
            }
        }
예제 #9
0
        public void Add_Uploads_Document_To_Folder_Test()
        {
            IQueryList <Document> lib = null;

            try
            {
                lib = _queryWeb.Create <Document>("Add_Uploads_Document_To_Folder_Test");

                var document = new Document
                {
                    Name    = "Add_Uploads_Document_To_Folder_Test.dat",
                    Content = new byte[] { 5, 10, 15, 25 },
                    Folder  = "Folder1/Folder2/Folder3",
                };
                lib.Add(document);

                var item = lib.Items(new CamlQuery()
                                     .Recursive()
                                     //  .Folder(document.Url)
                                     .Query(Q.Where(Q.Eq(Q.FieldRef <Document>(d => d.Name), Q.Value("Add_Uploads_Document_To_Folder_Test.dat")))))
                           .FirstOrDefault();

                Assert.IsNotNull(item);
                Assert.That(item.Id, Is.EqualTo(document.Id));
                Assert.That(item.Name, Is.EqualTo(document.Name));
                Assert.That(item.Content, Is.Not.Null);
                Assert.That(item.Content.Length, Is.EqualTo(document.Content.Length));
                Assert.That(item.Size, Is.EqualTo(4));
                Assert.That(item.Icon, Is.EqualTo("/_layouts/images/icgen.gif"));
                Assert.That(item.Folder, Is.EqualTo(document.Folder));
                //// Assert.That(item.Title, Is.EqualTo(document.Title));
            }
            finally
            {
                if (lib != null)
                {
                    lib.DeleteList(false);
                }
            }
        }
 public void Create_Creates_List_With_ContentType_Test()
 {
     using (var factory = WebFactory.Open(_webUrl))
     {
         IQueryList <Announcement> list = null;
         try
         {
             list = factory.Create <Announcement>("List756");
             Assert.AreEqual(list.Title, "List756");
             Assert.That(list.ContainsContentType <Item>(), Is.False);
             Assert.That(list.ContainsContentType <Announcement>());
             Assert.That(list.ContainsField(a => a.Body));
         }
         finally
         {
             if (null != list)
             {
                 list.DeleteList(false);
             }
         }
     }
 }
예제 #11
0
        public void Add_Uploads_Document_Test()
        {
            IQueryList <Document> lib = null;

            try
            {
                lib = _queryWeb.Create <Document>("Add_AddsCustomItem");
                var document = new Document
                {
                    Name    = "Add_AddsCustomItem.dat",
                    Content = new byte[] { 5, 10, 15, 25 },
                };
                lib.Add(document);

                var item = lib.Items(new CamlQuery()
                                     .Query(Q.Where(Q.Eq(Q.FieldRef <Document>(d => d.Name), Q.Value("Add_AddsCustomItem.dat")))))
                           .FirstOrDefault();

                Assert.IsNotNull(item);
                Assert.That(item.Id, Is.EqualTo(document.Id));
                Assert.That(item.Name, Is.EqualTo(document.Name));
                Assert.That(item.Content, Is.Not.Null);
                Assert.That(item.Content.Length, Is.EqualTo(document.Content.Length));
                Assert.That(item.Size, Is.EqualTo(4));
                Assert.That(item.Icon, Is.EqualTo("/_layouts/images/icgen.gif"));
                Assert.That(item.Folder, Is.EqualTo(document.Folder));
                Assert.NotNull(item.Url);
                Assert.That(item.Url, Is.EqualTo(SPUtility.ConcatUrls(_queryWeb.Web.ServerRelativeUrl, "/Add_AddsCustomItem/Add_AddsCustomItem.dat")));
            }
            finally
            {
                if (lib != null)
                {
                    lib.DeleteList(false);
                }
            }
        }
        public void ExistsById_Returns_Value_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <Item> list = null;

                try
                {
                    list = factory.Create <Item>("ExistsById_Returns_True_When_List_Exists_Test");
                    bool exists = factory.ExistsById(list.Id);
                    Assert.That(exists);

                    exists = factory.ExistsById(Guid.NewGuid());
                    Assert.That(exists == false);
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                }
            }
        }
        public void ExistsByUrl_Returns_Value_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <Item> list = null;

                try
                {
                    list = factory.Create <Item>("ExistsByUrl_Returns_True_When_List_Exists_Test");
                    bool exists = factory.ExistsByUrl(list.RelativeUrl);
                    Assert.That(exists);

                    exists = factory.ExistsByUrl("lists/ExistsByUrl_Returns_True_When_List_Exists_Test_Not_Existing");
                    Assert.That(exists == false);
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                }
            }
        }
예제 #14
0
 public void Stop()
 {
     _listForLookup.DeleteList(false);
     _queryWeb.Dispose();
 }
예제 #15
0
        public void Add_Uploads_CustomDocument_Test()
        {
            IQueryList <CustomDocument> list = null;

            try
            {
                var lookupItem = new Item {
                    Title = "Add_Adds_CustomItem_Test_Lookup"
                };
                _listForLookup.Add(lookupItem);

                var lookupItem2 = new Item {
                    Title = "Add_Adds_CustomItem_Test_Lookup_2"
                };
                _listForLookup.Add(lookupItem2);

                list = _queryWeb.Create <CustomDocument>("Add_Uploads_CustomDocument_Test");
                var customDoc = new CustomDocument
                {
                    Title             = "Add_Uploads_CustomDocument_Test",
                    Name              = "Add_Uploads_CustomDocument_Test",
                    Content           = new byte[] { 5, 10, 15, 25 },
                    CustomField1      = "Add_Uploads_CustomDocument_Test1",
                    CustomField2      = "Add_Uploads_CustomDocument_Test2",
                    CustomFieldNumber = 123.5,
                    CustomBoolean     = true,
                    CustomLookup      = lookupItem,
                    CustomMultiLookup = new List <Item> {
                        lookupItem, lookupItem2
                    },
                    CustomDate  = new DateTime(2011, 1, 11, 18, 15, 00),
                    CustomUser  = new Person(_firstUser.LoginName),
                    CustomUsers = new List <User> {
                        new Person(_firstUser.LoginName), new User(_spGroup.Name)
                    }
                };
                list.Add(customDoc);

                var item = list.Items(new CamlQuery()
                                      .Query(Q.Where(Q.Eq(Q.FieldRef <Document>(d => d.Name), Q.Value("Add_Uploads_CustomDocument_Test")))))
                           .FirstOrDefault();

                Assert.IsNotNull(item);
                Assert.That(item.Id, Is.EqualTo(customDoc.Id));

                Assert.That(item.Name, Is.EqualTo(customDoc.Name));
                Assert.That(item.Content, Is.Not.Null);
                Assert.That(item.Content.Length, Is.EqualTo(customDoc.Content.Length));
                Assert.That(item.Size, Is.EqualTo(4));
                Assert.That(item.Icon, Is.EqualTo("/_layouts/images/icgen.gif"));
                Assert.That(item.Folder, Is.EqualTo(customDoc.Folder));

                Assert.That(item.Title, Is.EqualTo(customDoc.Title));
                Assert.That(item.CustomField1, Is.EqualTo(customDoc.CustomField1));
                Assert.That(item.CustomField2, Is.EqualTo(customDoc.CustomField2));
                Assert.That(item.CustomFieldNumber, Is.EqualTo(customDoc.CustomFieldNumber));
                Assert.That(item.CustomBoolean, Is.EqualTo(customDoc.CustomBoolean));


                Assert.That(item.CustomDate, Is.EqualTo(new DateTime(2011, 1, 11, 18, 15, 00)).Within(1).Seconds);



                Assert.That(item.CustomLookup, Is.Not.Null);
                Assert.That(item.CustomLookup.Id, Is.EqualTo(lookupItem.Id));
                Assert.That(item.CustomMultiLookup, Is.Not.Null);
                Assert.That(item.CustomMultiLookup.Count(), Is.EqualTo(2));
                Assert.That(item.CustomMultiLookup.First().Title, Is.EqualTo(lookupItem.Title));

                Assert.That(item.CustomUser.GetType().ToString(), Is.EqualTo("Castle.Proxies.PersonProxy"));

                Assert.That(item.CustomUsers.Count(), Is.EqualTo(2));
                var users = item.CustomUsers.ToList();

                Assert.That(users[0].GetType().ToString(), Is.EqualTo("Castle.Proxies.PersonProxy"));
                Assert.That(users[1].GetType().ToString(), Is.EqualTo("Castle.Proxies.UserProxy"));
            }
            finally
            {
                if (list != null)
                {
                    list.DeleteList(false);
                }
            }
        }
예제 #16
0
        public void Add_Uploads_CustomDocument_Test()
        {
            IQueryList <CustomDocument> list = null;

            try
            {
                var lookupItem = new Item {
                    Title = "Add_Adds_CustomItem_Test_Lookup"
                };
                _listForLookup.Add(lookupItem);

                var lookupItem2 = new Item {
                    Title = "Add_Adds_CustomItem_Test_Lookup_2"
                };
                _listForLookup.Add(lookupItem2);

                list = _queryWeb.Create <CustomDocument>("Add_Uploads_CustomDocument_Test");
                var customDoc = new CustomDocument
                {
                    Title             = "Add_Uploads_CustomDocument_Test",
                    Name              = "Add_Uploads_CustomDocument_Test",
                    Content           = new byte[] { 5, 10, 15, 25 },
                    CustomField1      = "Add_Uploads_CustomDocument_Test1",
                    CustomField2      = "Add_Uploads_CustomDocument_Test2",
                    CustomFieldNumber = 123.5,
                    CustomBoolean     = true,
                    CustomLookup      = lookupItem,
                    CustomMultiLookup = new List <Item> {
                        lookupItem, lookupItem2
                    },
                    CustomDate = DateTime.Now,
                };
                list.Add(customDoc);

                var item = list.Items(new CamlQuery()
                                      .Query(Q.Where(Q.Eq(Q.FieldRef <Document>(d => d.Name), Q.Value("Add_Uploads_CustomDocument_Test")))))
                           .FirstOrDefault();

                Assert.IsNotNull(item);
                Assert.That(item.Id, Is.EqualTo(customDoc.Id));

                Assert.That(item.Name, Is.EqualTo(customDoc.Name));
                Assert.That(item.Content, Is.Not.Null);
                Assert.That(item.Content.Length, Is.EqualTo(customDoc.Content.Length));
                Assert.That(item.Size, Is.EqualTo(4));
                Assert.That(item.Icon, Is.EqualTo("/_layouts/images/icgen.gif"));
                Assert.That(item.Folder, Is.EqualTo(customDoc.Folder));

                Assert.That(item.Title, Is.EqualTo(customDoc.Title));
                Assert.That(item.CustomField1, Is.EqualTo(customDoc.CustomField1));
                Assert.That(item.CustomField2, Is.EqualTo(customDoc.CustomField2));
                Assert.That(item.CustomFieldNumber, Is.EqualTo(customDoc.CustomFieldNumber));
                Assert.That(item.CustomBoolean, Is.EqualTo(customDoc.CustomBoolean));
                Assert.That(item.CustomLookup, Is.Not.Null);
                Assert.That(item.CustomLookup.Id, Is.EqualTo(lookupItem.Id));
                Assert.That(item.CustomMultiLookup, Is.Not.Null);
                Assert.That(item.CustomMultiLookup.Count(), Is.EqualTo(2));
                Assert.That(item.CustomMultiLookup.First().Title, Is.EqualTo(lookupItem.Title));
            }
            finally
            {
                if (list != null)
                {
                    list.DeleteList(false);
                }
            }
        }