コード例 #1
0
        public async Task Existing_list_is_not_added()
        {
            ClientContext.Load(Web, w => w.ServerRelativeUrl);

            var list = await CreateList(
                l => l.Title,
                l => l.RootFolder.ServerRelativeUrl
                );

            var prov = new HarshList()
            {
                Title = list.Title,
                Url   = HarshUrl.GetRelativeTo(list.RootFolder.ServerRelativeUrl, Web.ServerRelativeUrl),
            };

            await prov.ProvisionAsync(Context);

            var output = LastObjectOutput <List>();

            Assert.False(output.ObjectAdded);

            var outputList = output.Object;

            Assert.NotNull(outputList);

            ClientContext.Load(
                outputList,
                l => l.Title
                );

            await ClientContext.ExecuteQueryAsync();

            Assert.Equal(list.Title, outputList.Title);
        }
コード例 #2
0
        public async Task Random_list_is_added()
        {
            var name = Guid.NewGuid().ToString("n");

            var prov = new HarshList()
            {
                Title = name,
                Url   = "Lists/" + name,
            };

            await prov.ProvisionAsync(Context);

            var objectCreated = LastObjectOutput <List>();

            Assert.IsType <ObjectAdded <List> >(objectCreated);

            var list = objectCreated.Object;

            Assert.NotNull(list);

            RegisterForDeletion(list);

            ClientContext.Load(
                list,
                l => l.Title,
                l => l.BaseTemplate
                );

            await ClientContext.ExecuteQueryAsync();

            Assert.NotNull(list);
            Assert.Equal(name, list.Title);
            Assert.Equal((Int32)ListTemplateType.GenericList, list.BaseTemplate);
        }
コード例 #3
0
        public async Task Content_type_gets_added()
        {
            var name = Guid.NewGuid().ToString("n");
            var ctid = HarshContentTypeId.Parse("0x01").Append(HarshContentTypeId.Parse(name));

            var ctProv = new HarshContentType()
            {
                Id   = ctid,
                Name = name,
            };

            var listProv = new HarshList()
            {
                Title = name,
                Url   = "Lists/" + name,

                Children =
                {
                    new HarshContentTypeRef()
                    {
                        ContentTypes = Resolve.ContentType().ById(ctid)
                    }
                }
            };

            await ctProv.ProvisionAsync(Context);

            var ctResult = LastObjectOutput <ContentType>();
            var ct       = ctResult.Object;

            RegisterForDeletion(ct);

            await listProv.ProvisionAsync(Context);

            var listResult = LastObjectOutput <List>();
            var list       = listResult.Object;

            RegisterForDeletion(list);

            Assert.IsType <ObjectAdded <List> >(listResult);
            Assert.NotNull(list);

            ClientContext.Load(
                list,
                l => l.ContentTypesEnabled,
                l => l.ContentTypes.Include(lct => lct.StringId),
                l => l.Id
                );

            await ClientContext.ExecuteQueryAsync();

            Assert.True(list.ContentTypesEnabled);
            Assert.Contains(list.ContentTypes, lct => lct.StringId.StartsWith(ctid.ToString() + "00"));
        }
コード例 #4
0
        private async Task <List> EnsureTargetList()
        {
            var list = new HarshList()
            {
                Title = "HarshPoint Tests Lookup Target List",
                Url   = TargetListUrl,
            };

            await list.ProvisionAsync(Context);

            return(LastObjectOutput <List>()?.Object);
        }