public void Start()
        {
            _queryWeb = WebFactory.Open(_webUrl);

            if (_queryWeb.ExistsByName(ListForLookup))
            {
                _listForLookup = _queryWeb.GetByName <Item>(ListForLookup);
            }
            else
            {
                _listForLookup = _queryWeb.Create <Item>(ListForLookup);
            }

            var users = _queryWeb.Web.SiteUsers.Cast <SPUser>().ToList();
            var uu    = users.Where(u => u.IsDomainGroup == false).ToList();

            _domainGroup = users.FirstOrDefault(u => u.IsDomainGroup);
            if (_domainGroup == null)
            {
                throw new Exception("No domain groups in site users!");
            }

            _spGroup = _queryWeb.Web.SiteGroups[0];

            _firstUser  = uu[0];
            _secondUser = uu[1];
        }
        public void Create_Creates_List_With_Custom_Nullable_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <NullableItem> list = null;
                try
                {
                    list = factory.Create <NullableItem>("Create_Creates_List_With_Custom_Nullable_Test");

                    list.ContainsField(i => i.CustomDouble);
                    list.ContainsField(i => i.CustomInt);
                    list.ContainsField(i => i.CustomDecimal);
                    list.ContainsField(i => i.CustomBoolean);
                    list.ContainsField(i => i.CustomDate);
                    list.ContainsField(i => i.CustomChoice);
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                }
            }
        }
Esempio n. 3
0
        private void SetParentWeb(object receiver, SPWeb web)
        {
            var prop = receiver.GetType().GetProperty("ParentWeb");
            var qweb = WebFactory.Open(web);

            prop.SetValue(receiver, qweb);
        }
Esempio n. 4
0
        public TestListScope(string testListName, bool ensureLookupList = false)
        {
            try
            {
                Web = WebFactory.Open(Settings.TestSiteUrl);

                if (ensureLookupList)
                {
                    EnsureListForLookup();
                }

                if (Web.ExistsByName(testListName))
                {
                    List = Web.GetByName <TList>(testListName);
                    List.DeleteList(false);
                    List = null;
                }

                List = Web.Create <TList>(testListName);
            }
            catch
            {
                Dispose();
                throw;
            }
        }
Esempio n. 5
0
        public VersionedElementViewModel(WebElementViewModel source, List <string> existedNames)
        {
            Source = source;
            var info = WebFactory.CreateInfoFromModel(source);

            Updated      = WebFactory.CreateModelFromInfo(info);
            ExistedNames = existedNames;
        }
 public void Create_Creates_DocLibrary_Test()
 {
     using (var factory = WebFactory.Open(_webUrl))
     {
         var list = factory.Create <Document>("List757");
         Assert.AreEqual(list.Title, "List757");
         Assert.That(list.ContainsContentType <Document>());
         list.DeleteList(false);
     }
 }
        public void Start()
        {
            _queryWeb = WebFactory.Open(_webUrl);

            if (_queryWeb.ExistsByName(ListForLookup))
            {
                _listForLookup = _queryWeb.GetByName <Item>(ListForLookup);
            }
            else
            {
                _listForLookup = _queryWeb.Create <Item>(ListForLookup);
            }
        }
        public void Open_By_Ids_Creates_QueryWeb_Test()
        {
            Guid siteId, webId;

            using (var wf = WebFactory.Open(_webUrl))
            {
                siteId = wf.Site.ID;
                webId  = wf.Web.ID;
            }

            using (var wf = WebFactory.Open(siteId, webId))
            {
            }
        }
        public void Create_Creates_List_With_Custom_Fields_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <Item> list1;
                try
                {
                    list1 = factory.Create <Item>("ListForLookup");
                }
                catch (SPException)
                {
                    list1 = factory.GetByName <Item>("ListForLookup");
                }
                IQueryList <CustomItem> list = null;
                try
                {
                    list = factory.Create <CustomItem>("List755");

                    Assert.AreEqual(list.Title, "List755");

                    Assert.That(list1.ContainsContentType <Item>());

                    Assert.That(list.ContainsField(ci => ci.CustomField1), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomField2), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomFieldNumber), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomBoolean), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomUser), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomUsers), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomLookup), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomMultiLookup), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomChoice), Is.True);
                    Assert.That(list.ContainsField(ci => ci.Тыдыщ), Is.True);

                    var choiceField = list.GetField(ci => ci.CustomChoice);
                    Assert.NotNull(choiceField.Choices);
                    Assert.That(choiceField.Choices.Count(), Is.EqualTo(3));
                    var choiceWithName = choiceField.Choices.Skip(1).First();
                    Assert.That(choiceWithName, Is.EqualTo("The Choice Number Two"));
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                    list1.DeleteList(false);
                }
            }
        }
Esempio n. 10
0
        public static IWebDriver SetUp(IWebDriver driver)
        {
            Logger.Info("inside SetupClass.Setup(driver)");
            //Factory Method which gets the browser from the App.config file
            Logger.Info("Creation of webFactory Object");
            WebFactory webFactory = new WebFactory();

            Logger.Info("Configuring driver to work with browser: " + ConfigurationManager.AppSettings["browser"]);
            driver = webFactory.GetWebDriver(ConfigurationManager.AppSettings["browser"]);
            Logger.Info("Driver returned: " + driver);

            //Opens the driver and goes to the URL specified in the App.config file
            driver.Manage().Window.Maximize();
            Logger.Info("Go to URL " + ConfigurationManager.AppSettings["URL"]);
            driver.Navigate().GoToUrl(ConfigurationManager.AppSettings["URL"]);
            return(driver);
        }
        public void Create_Creates_DocLibrary_With_Custom_Fields_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <Item>           list1 = null;
                IQueryList <CustomDocument> list  = null;

                try
                {
                    try
                    {
                        list1 = factory.Create <Item>("ListForLookup");
                    }
                    catch (SPException)
                    {
                        list1 = factory.GetByName <Item>("ListForLookup");
                    }
                    list = factory.Create <CustomDocument>("List759");

                    Assert.AreEqual(list.Title, "List759");

                    Assert.That(list.ContainsContentType <Item>() == false);
                    Assert.That(list.ContainsContentType <Document>());

                    Assert.That(list.ContainsField(ci => ci.CustomField1), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomField2), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomFieldNumber), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomBoolean), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomUser), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomUsers), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomLookup), Is.True);
                    Assert.That(list.ContainsField(ci => ci.CustomMultiLookup), Is.True);
                }
                finally
                {
                    if (list != null)
                    {
                        list.DeleteList(false);
                    }
                    if (list1 != null)
                    {
                        list1.DeleteList(false);
                    }
                }
            }
        }
Esempio n. 12
0
        public async Task <T> PutAsync <T>(string uri, object content, Dictionary <string, string> parameters, HttpStatusCode statusCode = HttpStatusCode.OK)
        {
            using (var client = WebFactory.CreateClient())
            {
                AddRequestHeaders(client);
                string endpoint     = GetEndpoint(uri, parameters);
                var    httpResponse = await client.PutAsJsonAsync(endpoint, content);

                var response = await httpResponse.Content.ReadFromJsonAsync <T>();

                if (statusCode == HttpStatusCode.OK)
                {
                    response.Should().NotBeNull();
                }
                httpResponse.StatusCode.Should().Be(statusCode);
                return(response);
            }
        }
Esempio n. 13
0
        public void Start()
        {
            var queryWeb = WebFactory.Open(Settings.TestSiteUrl);


            var users = queryWeb.Web.SiteUsers.Cast <SPUser>().ToList();
            var uu    = users.Where(u => u.IsDomainGroup == false).ToList();

            _domainGroup = users.FirstOrDefault(u => u.IsDomainGroup);
            if (_domainGroup == null)
            {
                throw new Exception("No domain groups in site users!");
            }

            _spGroup = queryWeb.Web.SiteGroups[0];

            _firstUser  = uu[0];
            _secondUser = uu[1];
        }
        public void Create_Creates_List_Test()
        {
            using (var factory = WebFactory.Open(_webUrl))
            {
                IQueryList <Item> list = null;
                try
                {
                    list = factory.Create <Item>("List754");
                    Assert.AreEqual(list.Title, "List754");

                    Assert.That(list.ContainsContentType <Item>());
                }
                finally
                {
                    if (null != list)
                    {
                        list.DeleteList(false);
                    }
                }
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //Panel2.Visible = true;
        //TreeView1.Visible = true;
        if (WebFactory.validateUser(Session.SessionID))
        {
//TextBox1.Visible = false;
            //    TextBox2.Visible = false;
            //  Button3.Visible = false;
            //  Label1.Visible = false;
            //  Label2.Visible = false;
        }
        else
        {
            //TextBox1.Visible = true;
            //    TextBox2.Visible = true;
            //Button3.Visible = true;
            //Label1.Visible = true;
            //Label2.Visible = true;
        }
    }
 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);
          * }*/
     }
 }
Esempio n. 18
0
        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 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);
                    }
                }
            }
        }
Esempio n. 21
0
 public T ElevatedNew(Guid siteId, Guid webId)
 {
     return(CreateApp(WebFactory.Elevated(siteId, webId), true));
 }
Esempio n. 22
0
 public T ElevatedNew(string webUrl)
 {
     return(CreateApp(WebFactory.Elevated(webUrl), true));
 }
Esempio n. 23
0
 public T OpenNew(Guid siteId, Guid webId)
 {
     return(CreateApp(WebFactory.Open(siteId, webId), true));
 }
Esempio n. 24
0
 public T OpenNew(string webUrl)
 {
     return(CreateApp(WebFactory.Open(webUrl), true));
 }
Esempio n. 25
0
 public T ElevatedFromCurrentContext()
 {
     return(CreateApp(WebFactory.CurrentContext().Elevate(), true));
 }
Esempio n. 26
0
 public T ExistingWeb(SPWeb spWeb)
 {
     return(CreateApp(WebFactory.Open(spWeb), false));
 }
Esempio n. 27
0
 public T CurrentContext()
 {
     return(CreateApp(WebFactory.CurrentContext(), false));
 }
 public void Open_By_Url_Creates_QueryWeb_Test()
 {
     using (var wf = WebFactory.Open(_webUrl))
     {
     }
 }