public TestListScope(string testListName) { try { Web = WebFactory.Open(Settings.TestSiteUrl); if (Web.ExistsByName(testListName)) { List = Web.GetByName <TList>(testListName); List.DeleteList(false); List = null; } List = Web.Create <TList>(testListName); } catch { Dispose(); throw; } }
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); } } } }
public void SP() { using (var wf = WebFactory.Open(_webUrl)) { /* IQueryList<Item> list = null; * try * { * list = wf.Create<Item>("TryFolders"); * list.IsFolderCreationAllowed = true; * * var splist = list.List; * * var itm = splist.AddItem("/lists/TryFolders/f1", SPFileSystemObjectType.File, null); * itm["Title"] = "temp"; * itm.Update(); * * } * finally * { * if (list != null) list.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); } } } }
private IEnumerable <SPListItem> GetLookupItems() { if (_fieldLookup.Type == SPFieldType.Lookup) { var spfl = (SPFieldLookup)_fieldLookup; // Reload item, because it may been changed before lazy load requested using (var wf = WebFactory.Open(_listItem.Web.Url)) { var list = wf.Web.Lists[_listItem.ParentList.ID]; var item = list.GetItemById(_listItem.ID); var lkplist = wf.Web.Lists[new Guid(spfl.LookupList)]; var lkpValues = new SPFieldLookupValueCollection( item[spfl.InternalName] != null ? item[spfl.InternalName].ToString() : string.Empty); foreach (var lkpValue in lkpValues) { if (lkpValue.LookupId == 0) { yield return(null); } yield return(lkplist.GetItemById(lkpValue.LookupId)); } } } else { throw new NotImplementedException(); } }
public T OpenNew(Guid siteId, Guid webId) { return(CreateApp(WebFactory.Open(siteId, webId), true)); }
public T OpenNew(string webUrl) { return(CreateApp(WebFactory.Open(webUrl), true)); }
public T ExistingWeb(SPWeb spWeb) { return(CreateApp(WebFactory.Open(spWeb), false)); }
public void Open_By_Url_Creates_QueryWeb_Test() { using (var wf = WebFactory.Open(_webUrl)) { } }