Пример #1
0
        public void ContentTemplate_GetNewItemNodes()
        {
            CreatePlayGround();

            Assert.IsTrue(GenericScenario.GetNewItemNodes(TestList, new ContentType[0]).Count() == 0, "#0 new item list is not empty");

            var itemsForList1 = GenericScenario.GetNewItemNodes(TestList).ToList();

            Assert.IsTrue(itemsForList1.Count(ct => ct.Path.Equals(_fileTemplate2.Path)) == 1, "#1 " + _fileTemplate2.Path + " not found");
            Assert.IsTrue(itemsForList1.Count(ct => ct.Path.Equals(_fileGlobalTemplate1.Path)) == 0, "#2 " + _fileGlobalTemplate1.Path + " found");

            var itemsForList2 = GenericScenario.GetNewItemNodes(_list2).ToList();

            Assert.IsTrue(itemsForList2.Count(ct => ct.Path.Equals(_fileTemplate2.Path)) == 0, "#3 " + _fileTemplate2.Path + " found");
            Assert.IsTrue(itemsForList2.Count(ct => ct.Path.Equals(_fileTemplate1.Path)) == 1, "#4 " + _fileTemplate1.Path + " not found");

            var itemsForWorkspace = GenericScenario.GetNewItemNodes(TestWorkspace).ToList();

            Assert.IsTrue(itemsForWorkspace.Count(ct => ct.Path.Equals(_listTemplate1.Path)) == 1, "#5 " + _listTemplate1.Path + " not found");
            Assert.IsTrue(itemsForWorkspace.Count(ct => ct.Path.Equals(_listGlobalTemplate1.Path)) == 0, "#6 " + _listGlobalTemplate1.Path + " found");

            var itemsForWorkspace2 = GenericScenario.GetNewItemNodes(TestWorkspace2).ToList();

            Assert.IsTrue(itemsForWorkspace2.Count(ct => ct.Path.Equals(_fileTemplate1.Path)) == 1, "#7 " + _fileTemplate1.Path + " not found");
            Assert.IsTrue(itemsForWorkspace2.Count(ct => ct.Path.Equals(_listGlobalTemplate1.Path)) == 1, "#8 " + _listGlobalTemplate1.Path + " not found");

            var itemsForWorkspace3 = GenericScenario.GetNewItemNodes(TestWorkspace3).ToList();

            Assert.IsTrue(itemsForWorkspace3.Count(ct => ct.Path.Equals(_fileGlobalTemplate1.Path)) == 1, "#9 " + _fileGlobalTemplate1.Path + " not found");
            Assert.IsTrue(itemsForWorkspace3.Count(ct => ct.Path.Equals(_listGlobalTemplate1.Path)) == 1, "#10 " + _listGlobalTemplate1.Path + " not found");
        }
Пример #2
0
        // ================================================================================================ Methods

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (this.ContextNode == null)
            {
                return;
            }

            if (ShowExecutionTime)
            {
                Timer.Start();
            }

            UITools.AddScript(UITools.ClientScriptConfigurations.SNWallPath);

            UITools.AddPickerCss();
            UITools.AddScript(UITools.ClientScriptConfigurations.SNPickerPath);

            // get items for content types drowpdown in dropbox
            var gc       = new GenericContent(this.ContextNode, "Folder");
            var newItems = GenericScenario.GetNewItemNodes(gc, ContentType.GetContentTypes());

            string jsonData;

            using (var s = new MemoryStream())
            {
                var workData = newItems.Select(n => new ContentTypeItem {
                    value = n.Name, label = n.DisplayName
                }).OrderBy(n => n.label);
                var serializer = new DataContractJsonSerializer(typeof(ContentTypeItem[]));
                serializer.WriteObject(s, workData.ToArray());
                s.Flush();
                s.Position = 0;
                using (var sr = new StreamReader(s))
                {
                    jsonData = sr.ReadToEnd();
                }
            }

            UITools.RegisterStartupScript("initdropboxautocomplete", string.Format("SN.Wall.initDropBox({0})", jsonData), this.Page);

            if (ShowExecutionTime)
            {
                Timer.Stop();
            }
        }