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"));
        }
예제 #3
0
        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");
        }
예제 #4
0
        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"));
        }
예제 #5
0
        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"));
        }
예제 #6
0
        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");
        }
예제 #7
0
        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");
        }
예제 #8
0
        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();
                }
            }
        }
예제 #9
0
        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"));
        }
예제 #10
0
        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");
        }
예제 #11
0
        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"));
        }
예제 #12
0
        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"));
        }
예제 #13
0
        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");
        }