public void FallbackToPageId()
            {
                Page page = new UserPage
                            {
                    PageId = 1,
                    Controls = new ControlList()
                };

                // Test no page or menu title (returns "Page [PageId]");
                Assert.AreEqual(page.GetNonNullMenuTitle(), string.Format("Page {0}", page.PageId));
            }
            public void FallbackToPageTitle()
            {
                Page page = new UserPage
                            {
                    PageId = 1,
                    Controls = new ControlList(),
                    PageTitle = "Test Page Title"
                };

                // Test no menu title (returns page title);
                Assert.AreEqual(page.GetNonNullMenuTitle(), page.PageTitle);
            }
            public void UsesMenuTitleFirst()
            {
                Page page = new UserPage
                            {
                    PageId = 1,
                    Controls = new ControlList(),
                    PageTitle = "Test Page Title",
                    MenuTitle = "Test Menu Title"
                };

                // Test with menu title (returns menu title)
                Assert.AreEqual(page.GetNonNullMenuTitle(), page.MenuTitle);
            }
        public void WriteProductPdfWithEveryControl()
        {
            ControlList list = ControlListActivator.CreateControlList();
            var entitlements = new List<ControlAccess>();
            entitlements.AddRange(list.Select(c => new ControlAccess(c.Id, AccessLevel.Write)));

            ProductPdfWriter writer = new ProductPdfWriter();
            ProductDefinition product = new ProductDefinition
                                            {
                                                FormDefinition = new FormDefinition { Pages = new PageList() }
                                            };
            Page page = new UserPage();
            product.FormDefinition.Pages.Add(page);
            page.Controls = list;

            using (MemoryStream stream = new MemoryStream())
            {
                writer.WritePdfToStream(product, entitlements, stream);
            }
        }
            public void TestInitialize()
            {
                int i = 1;

                this.pageList = new PageList();
                this.controlList = new ControlList();
                this.rootControl = new TextControl { Id = i++, Name = "RootControl" };
                this.outerRepeat = new RepeaterControl { Id = i++, Name = "OuterRepeater" };
                this.outerChild = new TextControl { Id = i++, Name = "OuterChild", ParentId = this.outerRepeat.Id };
                this.innerRepeat = new RepeaterControl { Id = i++, Name = "InnerRepeater", ParentId = this.outerRepeat.Id };
                this.innerChild = new TextControl { Id = i++, Name = "InnerChild", ParentId = this.innerRepeat.Id };

                this.onAnotherPage = new TextControl { Id = i + 1, Name = "OnAnotherPage" };

                this.innerRepeat.AddChild(this.innerChild);
                this.outerRepeat.AddChild(this.innerRepeat);
                this.outerRepeat.AddChild(this.outerChild);
                this.controlList.Add(this.rootControl);
                this.controlList.Add(this.outerRepeat);

                Page first = new UserPage
                        {
                            Controls = this.controlList
                        };

                Page second = new UserPage
                              {
                                  Controls = new ControlList
                                             {
                                                 this.onAnotherPage
                                             }
                              };

                this.pageList.Add(first);
                this.pageList.Add(second);
            }