Exemplo n.º 1
0
        public void DynamicWidgets_ParentRelationType_DisplayRelatedItemsOnFrontend()
        {
            string url;
            string responseContent;
            string expectedContent;
            string pageName = "FeatherPage";
            string pageUrl  = "featherpage";
            string item1    = "item1";
            string item2    = "item2";

            foreach (var color in this.colors)
            {
                ServerOperationsFeather.DynamicModule1Operations().CreateColor(color);
            }

            try
            {
                string[] item1RelatedColors = new string[] { this.colors[0], this.colors[1] };

                ServerOperationsFeather.DynamicModule2Operations().CreateItem(item1, item1RelatedColors);

                string[] item2RelatedColors = new string[] { this.colors[2], this.colors[3] };

                ServerOperationsFeather.DynamicModule2Operations().CreateItem(item2, item2RelatedColors);

                this.pageId = ServerOperations.Pages().CreatePage(pageName);

                var itemsWidget  = this.CreateMvcWidget(ResolveTypeItem, WidgetNameItem, RelatedFieldName, ResolveTypeColor, RelationDirection.Parent);
                var colorsWidget = this.CreateMvcWidget(ResolveTypeColor, WidgetNameColor);

                var controls = new List <System.Web.UI.Control>();
                controls.Add(itemsWidget);
                controls.Add(colorsWidget);

                PageContentGenerator.AddControlsToPage(this.pageId, controls);

                url             = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + this.colors[0]);
                responseContent = PageInvoker.ExecuteWebRequest(url);

                expectedContent = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + item1);
                Assert.IsTrue(this.ContainsElement(responseContent, expectedContent), "Link to " + item1 + " was not found on the frontend");

                expectedContent = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + item2);
                Assert.IsFalse(this.ContainsElement(responseContent, expectedContent), "Link to " + item2 + " was found on the frontend, but it shouldn't");

                url             = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + this.colors[3]);
                responseContent = PageInvoker.ExecuteWebRequest(url);

                expectedContent = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + item2);
                Assert.IsTrue(this.ContainsElement(responseContent, expectedContent), "Link to " + item2 + " was not found on the frontend");

                expectedContent = UrlPath.ResolveAbsoluteUrl("~/" + pageUrl + "/" + item1);
                Assert.IsFalse(this.ContainsElement(responseContent, expectedContent), "Link to " + item1 + " was found on the frontend, but it shouldn't");
            }
            finally
            {
                ServerOperations.Pages().DeleteAllPages();
            }
        }