Ejemplo n.º 1
0
        public static void Initialize(TestContext testContext)
        {
            var results = TestScope.ExecuteCommand("Get-PnPList");
            var list    = results[0].BaseObject as Microsoft.SharePoint.Client.List;

            listTitle = list.Title;
        }
Ejemplo n.º 2
0
        public void GetPnPFolderTest()
        {
            var results = TestScope.ExecuteCommand("Get-PnPFolder",
                                                   new CommandParameter("Url", "Shared Documents"));

            Assert.AreEqual(results.Count, 1);
        }
Ejemplo n.º 3
0
 public static void Cleanup()
 {
     TestScope.ExecuteCommand("Remove-PnPFolder",
                              new CommandParameter("Name", folderName),
                              new CommandParameter("Folder", "Shared Documents"),
                              new CommandParameter("Force"));
 }
 public static void Initialize(TestContext testContext)
 {
     listTitle = $"TempList {Guid.NewGuid()}";
     TestScope.ExecuteCommand("New-PnPList",
                              new CommandParameter("Title", listTitle),
                              new CommandParameter("Template", Microsoft.SharePoint.Client.ListTemplateType.GenericList));
 }
        public void RequestPnPReIndexListTest()
        {
            var results = TestScope.ExecuteCommand("Request-PnPReIndexList",
                                                   new CommandParameter("Identity", listTitle));

            Assert.AreEqual(results.Count, 0);
        }
Ejemplo n.º 6
0
        public void GetPnPViewTest()
        {
            var results = TestScope.ExecuteCommand("Get-PnPView",
                                                   new CommandParameter("List", listTitle));

            Assert.IsTrue(results.Count > 0);
        }
Ejemplo n.º 7
0
        public static void Initialize(TestContext testContext)
        {
            folderName = $"Folder_{Guid.NewGuid()}";

            TestScope.ExecuteCommand("Add-PnPFolder",
                                     new CommandParameter("Name", folderName),
                                     new CommandParameter("Folder", "Shared Documents"));
        }
Ejemplo n.º 8
0
        public void RemovePnPListTest()
        {
            var results = TestScope.ExecuteCommand("Remove-PnPList",
                                                   new CommandParameter("Identity", listTitle),
                                                   new CommandParameter("Force"));

            Assert.IsNotNull(results);
        }
Ejemplo n.º 9
0
        public void NewPnPListTest()
        {
            var results = TestScope.ExecuteCommand("New-PnPList",
                                                   new CommandParameter("Title", listTitle),
                                                   new CommandParameter("Template", Microsoft.SharePoint.Client.ListTemplateType.GenericList));

            Assert.AreEqual(results.Count, 1);
        }
Ejemplo n.º 10
0
 public static void Initialize(TestContext testContext)
 {
     listTitle = $"TempList {Guid.NewGuid()}";
     viewTitle = "TestView";
     TestScope.ExecuteCommand("New-PnPList",
                              new CommandParameter("Title", listTitle),
                              new CommandParameter("Template", ListTemplateType.GenericList));
 }
Ejemplo n.º 11
0
        public void GetPnPListItemTest()
        {
            var results = TestScope.ExecuteCommand("Get-PnPListItem",
                                                   new CommandParameter("List", listTitle),
                                                   new CommandParameter("Id", itemId));

            Assert.AreEqual(results.Count, 1);
        }
Ejemplo n.º 12
0
        public void GetPnPFolderItemTest()
        {
            var results = TestScope.ExecuteCommand("Get-PnPFolderItem",
                                                   new CommandParameter("FolderSiteRelativeUrl", "Shared Documents")
                                                   );

            Assert.IsTrue(results.Count > 0);
        }
Ejemplo n.º 13
0
        public void AddPnPFolderTest()
        {
            var results = TestScope.ExecuteCommand("Add-PnPFolder",
                                                   new CommandParameter("Name", folderName),
                                                   new CommandParameter("Folder", "Shared Documents"));

            Assert.AreEqual(results.Count, 1);
        }
Ejemplo n.º 14
0
        //TODO: This is a scaffold of the cmdlet - complete the unit test
        //[TestMethod]
        public void RemovePnPFieldTest()
        {
            var results = TestScope.ExecuteCommand("Remove-PnPField",
                                                   new CommandParameter("Identity", fieldName),
                                                   new CommandParameter("Force"));

            Assert.AreEqual(results.Count, 0);
        }
Ejemplo n.º 15
0
        //TODO: This is a scaffold of the cmdlet - complete the unit test
        //[TestMethod]
        public void RemovePnPFileTest()
        {
            var results = TestScope.ExecuteCommand("Remove-PnPFile",
                                                   new CommandParameter("SiteRelativeUrl", $"Shared Documents/{fileName}"),
                                                   new CommandParameter("Force"));

            Assert.AreEqual(results.Count, 0);
        }
Ejemplo n.º 16
0
        public void GetPnPSpecifiedViewTest()
        {
            var results = TestScope.ExecuteCommand("Get-PnPView",
                                                   new CommandParameter("List", listTitle),
                                                   new CommandParameter("Identity", viewTitle));

            Assert.AreEqual(results.Count, 1);
        }
Ejemplo n.º 17
0
        public void GetPnPFileAsListItemTest()
        {
            var results = TestScope.ExecuteCommand("Get-PnPFile",
                                                   new CommandParameter("Url", $"Shared Documents/{fileName}"),
                                                   new CommandParameter("AsListItem"));

            Assert.AreEqual(results.Count, 1);
            Assert.IsInstanceOfType(results[0].BaseObject, typeof(Microsoft.SharePoint.Client.ListItem));
        }
Ejemplo n.º 18
0
        //TODO: This is a scaffold of the cmdlet - complete the unit test
        //[TestMethod]
        public void AddPnPFieldTest()
        {
            var results = TestScope.ExecuteCommand("Add-PnPField",
                                                   new CommandParameter("DisplayName", fieldName),
                                                   new CommandParameter("InternalName", fieldName),
                                                   new CommandParameter("Type", Microsoft.SharePoint.Client.FieldType.Text));

            Assert.IsTrue(results.Count > 0);
        }
Ejemplo n.º 19
0
        public void RemovePnPViewTest()
        {
            var results = TestScope.ExecuteCommand("Remove-PnPView",
                                                   new CommandParameter("Identity", viewTitle),
                                                   new CommandParameter("List", listTitle),
                                                   new CommandParameter("Force"));

            Assert.AreEqual(results.Count, 0);
        }
Ejemplo n.º 20
0
        public void GetPnPFileAsStringTest()
        {
            var results = TestScope.ExecuteCommand("Get-PnPFile",
                                                   new CommandParameter("Url", $"Shared Documents/{fileName}"),
                                                   new CommandParameter("AsString"));

            Assert.AreEqual(results.Count, 1);
            Assert.IsInstanceOfType(results[0].BaseObject, typeof(string));
        }
Ejemplo n.º 21
0
        public static void Initialize(TestContext testContext)
        {
            fileName = $"{Guid.NewGuid()}.txt";
            var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @$ "Resources{System.IO.Path.DirectorySeparatorChar}template.xml");

            TestScope.ExecuteCommand("Add-PnPFile",
                                     new CommandParameter("Path", filePath),
                                     new CommandParameter("NewFileName", fileName),
                                     new CommandParameter("Folder", "Shared Documents"));
        }
Ejemplo n.º 22
0
        public void AddPnPFileTest()
        {
            var filePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @$ "Resources{System.IO.Path.DirectorySeparatorChar}template.xml");
            var results  = TestScope.ExecuteCommand("Add-PnPFile",
                                                    new CommandParameter("Path", filePath),
                                                    new CommandParameter("NewFileName", fileName),
                                                    new CommandParameter("Folder", "Shared Documents"));

            Assert.IsTrue(results.Count > 0);
        }
Ejemplo n.º 23
0
        public static void Cleanup(TestContext testContext)
        {
            TestScope.ExecuteCommand("Remove-PnPField",
                                     new CommandParameter("Identity", fieldName),
                                     new CommandParameter("Force"));

            TestScope.ExecuteCommand("Remove-PnPField",
                                     new CommandParameter("Identity", $"{fieldName}2"),
                                     new CommandParameter("List", list.Title),
                                     new CommandParameter("Force"));
        }
Ejemplo n.º 24
0
        public static void Initialize(TestContext testContext)
        {
            fieldName = $"Field{Guid.NewGuid()}";

            var listResults = TestScope.ExecuteCommand("Get-PnPList");

            if (listResults.Count > 0)
            {
                list = listResults[0].BaseObject as Microsoft.SharePoint.Client.List;
            }
        }
Ejemplo n.º 25
0
        public void AddPnPViewTest()
        {
            var fields = new List <string>();

            fields.Add("Title");
            var results = TestScope.ExecuteCommand("Add-PnPView",
                                                   new CommandParameter("List", listTitle),
                                                   new CommandParameter("Title", viewTitle),
                                                   new CommandParameter("Fields", fields));

            Assert.AreEqual(results.Count, 1);
        }
Ejemplo n.º 26
0
        public void AddPnPListItemTest()
        {
            Hashtable values = new Hashtable();

            values.Add("Title", "Test Item");

            var results = TestScope.ExecuteCommand("Add-PnPListItem",
                                                   new CommandParameter("List", listTitle),
                                                   new CommandParameter("Values", values));

            Assert.AreEqual(results.Count, 1);
        }
Ejemplo n.º 27
0
        public static void Initialize(TestContext testContext)
        {
            listTitle = $"TempList {Guid.NewGuid()}";
            TestScope.ExecuteCommand("New-PnPList",
                                     new CommandParameter("Title", listTitle),
                                     new CommandParameter("Template", Microsoft.SharePoint.Client.ListTemplateType.GenericList));

            viewTitle = "TempView";
            TestScope.ExecuteCommand("Add-PnPView",
                                     new CommandParameter("List", listTitle),
                                     new CommandParameter("Title", viewTitle),
                                     new CommandParameter("Fields", new string[] { "Title" }));
        }
Ejemplo n.º 28
0
        public void GetPnPFieldForListTest()
        {
            var listResults = TestScope.ExecuteCommand("Get-PnPList");

            if (listResults.Count > 0)
            {
                var list    = listResults[0].BaseObject as Microsoft.SharePoint.Client.List;
                var results = TestScope.ExecuteCommand("Get-PnPField", new CommandParameter("List", list));
                Assert.IsTrue(results.Count > 0);
            }
            else
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 29
0
        //TODO: This is a scaffold of the cmdlet - complete the unit test
        //[TestMethod]
        public void SetPnPListItemTest()
        {
            Hashtable values = new Hashtable();

            values.Add("Title", "Updated Item");
            var results = TestScope.ExecuteCommand("Set-PnPListItem",
                                                   new CommandParameter("List", listTitle),
                                                   new CommandParameter("Identity", itemId),
                                                   new CommandParameter("Values", values));

            Assert.AreEqual(results.Count, 1);

            var item = (ListItem)results[0].BaseObject;

            Assert.AreEqual(item["Title"], "Updated Item");
        }
Ejemplo n.º 30
0
        public void AddPnPFieldToListTest()
        {
            if (list != null)
            {
                var results = TestScope.ExecuteCommand("Add-PnPField",
                                                       new CommandParameter("List", list.Title),
                                                       new CommandParameter("DisplayName", $"{fieldName}2"),
                                                       new CommandParameter("InternalName", $"{fieldName}2"),
                                                       new CommandParameter("Type", Microsoft.SharePoint.Client.FieldType.Text));

                Assert.IsTrue(results.Count > 0);
            }
            else
            {
                Assert.Fail();
            }
        }