Ejemplo n.º 1
0
        public void ProvisioningEngine_adds_default_data()
        {
            using (var context = new SPOEmulationContext(_isolationLevel, _url))
            {
                var sut = new ProvisioningEngine();
                // ensure the list
                sut.CreateDefaultList(context.ClientContext, context.ClientContext.Web);
                var list = context.ClientContext.Web.Lists.GetByTitle("Default List");
                context.ClientContext.Load(list);

                // add items to list
                sut.AddDeaultData(context.ClientContext, list);

                // reload items validate
                var query = CamlQuery.CreateAllItemsQuery();
                var items = list.GetItems(query);
                context.ClientContext.Load(items);
                context.ClientContext.ExecuteQuery();

                Assert.AreEqual(5, items.Count);

                // Delete list if we do integration testing
                if (_isolationLevel != IsolationLevel.Fake)
                {
                    list.DeleteObject();
                    context.ClientContext.ExecuteQuery();
                }
            }
        }
Ejemplo n.º 2
0
        public void ProvisioningEngine_default_list_contains_fields()
        {
            using (var context = new SPOEmulationContext(_isolationLevel, _url))
            {
                var sut = new ProvisioningEngine();
                sut.CreateDefaultList(context.ClientContext, context.ClientContext.Web);

                var result = context.ClientContext.Web.Lists.GetByTitle("Default List");
                context.ClientContext.Load(result);
                context.ClientContext.ExecuteQuery();

                // Check that the list contains fields.
                var field1 = result.Fields.GetByTitle("My Number1");
                var field2 = result.Fields.GetByTitle("My Number2");
                context.ClientContext.Load(field1);
                context.ClientContext.Load(field2);
                context.ClientContext.ExecuteQuery();
                Assert.IsNotNull(field1);
                Assert.IsNotNull(field2);

                // Delete list if we do integration testing
                if (_isolationLevel != IsolationLevel.Fake)
                {
                    result.DeleteObject();
                    context.ClientContext.ExecuteQuery();
                }
            }
        }
Ejemplo n.º 3
0
        public void ProvisioningEngine_sets_web_title_to_department_name()
        {
            using (var context = new SPOEmulationContext(_isolationLevel, Settings.Default.Url))
            {
                // Get title
                context.ClientContext.Load(context.ClientContext.Web, w => w.Title);
                context.ClientContext.ExecuteQuery();
                var originalTitle = context.ClientContext.Web.Title;

                var sut = new ProvisioningEngine();
                
                // set title of web to department name
                sut.SetDepartmentTitle(context.ClientContext, context.ClientContext.Web);
                
                context.ClientContext.Load(context.ClientContext.Web, w => w.Title);
                context.ClientContext.ExecuteQuery();
                Assert.AreEqual("Department A", context.ClientContext.Web.Title);

                // Clean up title for integration testing
                if (_isolationLevel != IsolationLevel.Fake)
                {
                    context.ClientContext.Web.Title = originalTitle;
                    context.ClientContext.Web.Update();
                    context.ClientContext.ExecuteQuery();
                }
            }
        }
Ejemplo n.º 4
0
        public void ProvisioningEngine_creates_default_list()
        {
            using (var context = new SPOEmulationContext(_isolationLevel, _url))
            {
                var sut = new ProvisioningEngine();
                sut.CreateDefaultList(context.ClientContext, context.ClientContext.Web);

                var result = context.ClientContext.Web.Lists.GetByTitle("Default List");
                context.ClientContext.Load(result);
                context.ClientContext.ExecuteQuery();

                Assert.IsNotNull(result);
                Assert.AreEqual("A default list that is provisioned.", result.Description);
                Assert.IsTrue(result.EnableVersioning);


                // Delete list if we do integration testing
                if (_isolationLevel != IsolationLevel.Fake)
                {
                    result.DeleteObject();
                    context.ClientContext.ExecuteQuery();
                }
            }
        }