예제 #1
0
        private void t05_AddDocument1(SPOTestSystem ts, bool isLibrary, string listName)
        {
            SPOClient spoc = createClient(ts) as SPOClient;

            spoc.Login();

            // Create list or library with one column
            SPOList spol = createListOrLibrary(spoc, isLibrary, listName,
                                               new List <SPOClient.FieldSpec>()
            {
                new SPOClient.FieldSpec()
                {
                    Name = "mySingleTextLine", Type = "Text"
                }
            });

            // Test without and with subfodlers.
            // Always twice to handle the case where stuff already exists.
            addDocument(spoc, spol, "/MyFirstDocument.pdf");
            addDocument(spoc, spol, "MyFirstDocument.pdf");
            addDocument(spoc, spol, "sub/subsub/MyFirstDocument.pdf");
            addDocument(spoc, spol, "/sub/subsub/MySecondDocument.pdf");

            deleteListOrLibrary(spoc, listName);
        }
예제 #2
0
        private ISPOClient createClient(SPOTestSystem ts)
        {
            SPOClient spoClient = new SPOClient();

            spoClient.Office365 = ts.Office365;
            spoClient.SiteUrl   = ts.SiteUrl;
            spoClient.Username  = ts.Username;
            spoClient.SetPassowrd(ts.Password);
            spoClient.ClientCulture = new CultureInfo("en-US", false);
            return(spoClient);
        }
예제 #3
0
        private void t01_Login1(SPOTestSystem ts)
        {
            // Confirm regular login
            ISPOClient spoClient = createClient(ts);

            spoClient.Login();

            // Confirm failure with wrong password
            bool gotError = false;

            spoClient.SetPassowrd(ts.Password + "_illegal");
            try { spoClient.Login(); }
            catch { gotError = true; }
            Assert.IsTrue(gotError);
        }
예제 #4
0
        private void t06_ColumnTypes1(SPOTestSystem ts)
        {
            SPOClient spoc = createClient(ts) as SPOClient;

            spoc.Login();

            SPOList spol = createListOrLibrary(spoc, false, unitTestList);

            var td = new[]
            {
                new { n = 00, type = "Text", value = "HelloWorld", culture = "en-US" },
                new { n = 10, type = "DateTime", value = "02/15/2017", culture = "en-US" },
                new { n = 11, type = "DateTime", value = "15.02.2017", culture = "de-DE" },
                new { n = 12, type = "DateTime", value = "", culture = "de-DE" },
                new { n = 20, type = "Note", value = "Line1\nLine2", culture = "en-US" },
                new { n = 30, type = "Choice", value = "Berlin", culture = "en-US" },
                new { n = 40, type = "Number", value = "12.34", culture = "en-US" },
                new { n = 41, type = "Number", value = "12,34", culture = "de-DE" },
                new { n = 42, type = "Number", value = "", culture = "de-DE" },
                new { n = 50, type = "Currency", value = "14.22", culture = "en-US" },
                new { n = 51, type = "Currency", value = "", culture = "en-US" },
                new { n = 60, type = "Boolean", value = "False", culture = "en-US" },
                //new { n = 7, type = "Lookup", value = "abc", },
                //new { n = 8, type = "User", value = @"0#.w|vmsp2013\administrator", },
            };
            int doOnly = -1;

            for (int i = 0; i != td.Length; i++)
            {
                if (doOnly > 0 && td[i].n != doOnly)
                {
                    continue;
                }

                string name = "a" + td[i].type;
                string type = td[i].type;
                spoc.AddFieldToList(spol, new SPOClient.FieldSpec()
                {
                    Name = name, Type = type
                });
                spoc.ClientCulture = new CultureInfo(td[i].culture, false);
                testOneType(spoc, spol, type, name, td[i].value);
                spoc.DeleteField(spol, name);
            }
            Assert.IsTrue(doOnly < 0, "Not all tests executed");

            deleteListOrLibrary(spoc, unitTestList);
        }
예제 #5
0
        private void reallyRemoveTestLists(SPOTestSystem ts, string listname)
        {
            // http://stackoverflow.com/questions/42146301/deleting-list-does-not-work-list-does-not-exist

            SPOClient spoc = createClient(ts) as SPOClient;

            spoc.Login();

            try { spoc.DeleteList(listname); } catch (Exception e) { var x = e.Message; }
            spoc.CreateList(listname, false);

            spoc = createClient(ts) as SPOClient;
            spoc.Login();

            spoc.DeleteList(listname);
            spoc.Dispose();
        }
예제 #6
0
        private void t02_GetLists1(SPOTestSystem ts)
        {
            // Get all lists
            ISPOClient spoClient = createClient(ts);

            spoClient.Login();
            List <SPOList> result = spoClient.GetLists();

            // Verify we've got enough known lists
            Regex regex = new Regex(ts.ListPattern);

            Assert.IsTrue(ts.ListMin <= result.Where(n => regex.Match(n.Title).Success).Count());

            // Verify we've got several base types and template types
            Assert.IsTrue(0 < result.Select(n => n.BaseType).Distinct().Count());
            Assert.IsTrue(0 < result.Select(n => n.TemplateType).Distinct().Count());
        }
예제 #7
0
        private void t08_ListCreation1(SPOTestSystem ts)
        {
            SPOClient spoc = createClient(ts) as SPOClient;

            spoc.Login();

            string listname = unitTestList;

            //string listname = "abc";

            try { spoc.DeleteList(listname); } catch (Exception e) { var x = e.Message; }
            spoc.CreateList(listname, false);

            spoc = createClient(ts) as SPOClient;
            spoc.Login();

            spoc.DeleteList(listname);
        }
예제 #8
0
        private void t04_GetFields1(SPOTestSystem ts)
        {
            ISPOClient spoClient = createClient(ts);

            spoClient.Login();

            // Ensure there is a minimum number of field returned for our test library
            SPOList         testLibrary = ((SPOClient)spoClient).GetListByTitle(ts.TestLibrary);
            List <SPOField> result      = spoClient.GetFields(testLibrary);

            Assert.IsTrue(ts.FieldMin <= result.Count);
            Assert.AreEqual(1, result.Where(n => n.Title == "Title").Count());

            // Ensure the forcedField parameter worlds; "Title" should not matter.
            int cnt = result.Count;

            result = spoClient.GetFields(testLibrary, new List <string>()
            {
                "Name", "Title"
            });
            Assert.AreEqual(cnt + 1, result.Count);
        }