public void AddAddsToNewGroupIfGroupDoesntExist() { var list = new ListItemCollection<string>(); list.AddGroup("Hello", new List<string> { "Foo" }); list.Add("World", "Bar"); list.Should().HaveCount(2); list.Should().Contain(g => g.Title == "Hello" && g.Count == 1 && g[0] == "Foo"); list.Should().Contain(g => g.Title == "World" && g.Count == 1 && g[0] == "Bar"); }
public void AddAddsToExistingGroupIfGroupDoesExist() { var list = new ListItemCollection<string>(); list.AddGroup("Hello", new List<string> { "Foo" }); list.Add("Hello", "Bar"); list.Should().HaveCount(1); list.Should().Contain(g => g.Title == "Hello" && g.Count == 2 && g.Contains("Foo") && g.Contains("Bar")); }
public void DeleteDeletesItem() { var list = new ListItemCollection <string>(); list.AddGroup("Hello", new List <string> { "Foo", "Bar" }); list.Delete("Foo"); list.Should().HaveCount(1); list.Should().Contain(g => g.Title == "Hello" && g.Count == 1 && g[0] == "Bar"); }
public void DeleteReturnsFalseIfTheItemDoesnExist() { var list = new ListItemCollection <string>(); list.AddGroup("Hello", new List <string> { "Foo", "Bar" }); list.Delete("World").Should().BeFalse(); list.Should().HaveCount(1); list.Should().Contain(g => g.Title == "Hello" && g.Count == 2 && g.Contains("Foo") && g.Contains("Bar")); }
public void AddAddsToExistingGroupIfGroupDoesExist() { var list = new ListItemCollection <string>(); list.AddGroup("Hello", new List <string> { "Foo" }); list.Add("Hello", "Bar"); list.Should().HaveCount(1); list.Should().Contain(g => g.Title == "Hello" && g.Count == 2 && g.Contains("Foo") && g.Contains("Bar")); }
public void AddAddsToNewGroupIfGroupDoesntExist() { var list = new ListItemCollection <string>(); list.AddGroup("Hello", new List <string> { "Foo" }); list.Add("World", "Bar"); list.Should().HaveCount(2); list.Should().Contain(g => g.Title == "Hello" && g.Count == 1 && g[0] == "Foo"); list.Should().Contain(g => g.Title == "World" && g.Count == 1 && g[0] == "Bar"); }
public void GroupsAreSorted() { var list = new ListItemCollection <string>(); list.AddGroup("Bob", new List <string> { "Foo", "Bar" }); list.AddGroup("Dave", new List <string> { "Hello", "World" }); list.Should().HaveCount(2); list[0].Title.Should().Be("Bob"); list[1].Title.Should().Be("Dave"); list.TitleSortOrder = new List <string> { "Dave", "Colin", "Bob" }; list.Should().HaveCount(2); list[0].Title.Should().Be("Dave"); list[1].Title.Should().Be("Bob"); list.AddGroup("Colin", new List <string> { "FooBar", "HelloWorld" }); list.Should().HaveCount(3); list[0].Title.Should().Be("Dave"); list[1].Title.Should().Be("Colin"); list[2].Title.Should().Be("Bob"); list.Delete("FooBar"); list.Delete("HelloWorld"); list.Should().HaveCount(2); list[0].Title.Should().Be("Dave"); list[1].Title.Should().Be("Bob"); }
public void ShouldGetCategoryContent() { using (var ctx = SpImporter.SpImporter.CreateClientContext(appSettings)) { var web = ctx.Web; List oList = ctx.Web.Lists.GetByTitle("Pages"); ctx.Load(oList); ctx.ExecuteQuery(); CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = @"<View><Query><Where> <Eq> <FieldRef Name='ContentType'/> <Value Type='Computed'>RuleSummaryPage</Value> </Eq> </Where></Query><RowLimit>5000</RowLimit></View>"; ListItemCollection items = oList.GetItems(camlQuery); ctx.Load(items); ctx.ExecuteQuery(); var allContent = new Dictionary <string, string>(); items.Should().NotBeEmpty(); foreach (var item in items) { var contentType = item.ContentType; ctx.Load(item); ctx.Load(contentType); var file = ctx.Web.GetFileByServerRelativeUrl($"/Pages/{item["FileLeafRef"]}"); ctx.Load(file); ctx.ExecuteQuery(); if (item.ContentType.Name == "RuleSummaryPage") { var title = item["Title"]?.ToString(); var publishingPageContent = item["PublishingPageContent"]?.ToString(); var ruleSummaryIntro = item["RuleSummaryIntro"]?.ToString(); if (title != null) { allContent[title] = ruleSummaryIntro + publishingPageContent; } } } // test we have content for "Rules to Successful Projects" - was missing in earlier runs allContent["Rules to Successful Projects"].Should().NotBeNullOrEmpty(); using (var sw = new StreamWriter(@"c:\temp\categories.json", false)) { sw.Write(JsonConvert.SerializeObject(allContent)); sw.Flush(); } } }
public void DeleteRemovesEmptyGroups() { var list = new ListItemCollection <string>(); list.AddGroup("Hello", new List <string> { "Foo", "Bar" }); list.AddGroup("World", new List <string> { "FooBar" }); list.Should().HaveCount(2); list.Delete("FooBar").Should().BeTrue(); list.Should().HaveCount(1); list.Should().Contain(g => g.Title == "Hello" && g.Count == 2 && g.Contains("Foo") && g.Contains("Bar")); }
public void GroupsAreSorted() { var list = new ListItemCollection<string>(); list.AddGroup("Bob", new List<string> { "Foo", "Bar" }); list.AddGroup("Dave", new List<string> { "Hello", "World" }); list.Should().HaveCount(2); list[0].Title.Should().Be("Bob"); list[1].Title.Should().Be("Dave"); list.TitleSortOrder = new List<string> { "Dave", "Colin", "Bob" }; list.Should().HaveCount(2); list[0].Title.Should().Be("Dave"); list[1].Title.Should().Be("Bob"); list.AddGroup("Colin", new List<string> { "FooBar", "HelloWorld" }); list.Should().HaveCount(3); list[0].Title.Should().Be("Dave"); list[1].Title.Should().Be("Colin"); list[2].Title.Should().Be("Bob"); list.Delete("FooBar"); list.Delete("HelloWorld"); list.Should().HaveCount(2); list[0].Title.Should().Be("Dave"); list[1].Title.Should().Be("Bob"); }
public void DeleteReturnsFalseIfTheItemDoesnExist() { var list = new ListItemCollection<string>(); list.AddGroup("Hello", new List<string> { "Foo", "Bar" }); list.Delete("World").Should().BeFalse(); list.Should().HaveCount(1); list.Should().Contain(g => g.Title == "Hello" && g.Count == 2 && g.Contains("Foo") && g.Contains("Bar")); }
public void DeleteRemovesEmptyGroups() { var list = new ListItemCollection<string>(); list.AddGroup("Hello", new List<string> { "Foo", "Bar" }); list.AddGroup("World", new List<string> { "FooBar" }); list.Should().HaveCount(2); list.Delete("FooBar").Should().BeTrue(); list.Should().HaveCount(1); list.Should().Contain(g => g.Title == "Hello" && g.Count == 2 && g.Contains("Foo") && g.Contains("Bar")); }
public void DeleteDeletesItem() { var list = new ListItemCollection<string>(); list.AddGroup("Hello", new List<string> { "Foo", "Bar" }); list.Delete("Foo"); list.Should().HaveCount(1); list.Should().Contain(g => g.Title == "Hello" && g.Count == 1 && g[0] == "Bar"); }