Пример #1
0
        public void ToString_MovedRegion_AreEqual()
        {
            var debug = new DebugRegion(1, PlayerType.player2, 3);

            var act = debug.ToString();
            var exp = "ID: 1, Owner: player2, Armies: 3";

            Assert.AreEqual(exp, act);
        }
Пример #2
0
        public void ToString_Region_AreEqual()
        {
            var debug = new DebugRegion(8, PlayerType.player1, 8);

            var act = debug.ToString();
            var exp = "ID: 8, Owner: player1, Armies: 8";

            Assert.AreEqual(exp, act);
        }
        private void WriteHtml(IHtmlWriter html, DebugRegion region, int depth)
        {
            if (region.Element != null)
            {
                html.WriteElementLine("p", "zone inherits from '" + region.Element.Name + "' region");
                if (depth != 1)
                {
                    StartIndent(html, false);
                    WriteDebugInfo(html, region.Element.GetDebugInfo(), 2);
                    EndIndent(html);
                }
            }

            if (region.RepeatType != null)
            {
                html.WriteOpenTag("p");
                html.WriteText("Repeat region for each ");
                html.WriteElement("i", region.RepeatType.DisplayName());
                if (!string.IsNullOrEmpty(region.RepeatScope))
                {
                    html.WriteText(" in '" + region.RepeatScope + "' scope");
                }
                html.WriteText(" from ");
                html.WriteElement("i", region.ListType.DisplayName());
                if (!string.IsNullOrEmpty(region.ListScope))
                {
                    html.WriteText(" in '" + region.ListScope + "' scope");
                }
                html.WriteCloseTag("p");
                html.WriteLine();
            }

            if (region.Scope != null)
            {
                if (region.Scope.Scopes != null)
                {
                    html.WriteElementLine("p", "zone data scope");
                    StartIndent(html, false);
                    WriteDebugInfo(html, region.Scope, 3);
                    EndIndent(html);
                }
            }

            if (region.Children != null && region.Children.Count > 0)
            {
                html.WriteElementLine("p", "zone has contents");
                if (depth != 1)
                {
                    StartIndent(html, true);
                    WriteDebugInfo(html, region.Children[0], depth - 1);
                    EndIndent(html);
                }
            }
        }
Пример #4
0
 public static void AreEqual(PlayerType expOwner, int expArmies, DebugRegion act)
 {
     Assert.AreEqual(expOwner, act.Owner, "Owner[{0}]", act.Id);
     Assert.AreEqual(expArmies, act.Armies, "Armies[{0}]", act.Id);
 }
        public RegionDrawing(
            IDebugDrawing drawing,
            DrawingElement page,
            DebugRegion debugRegion,
            int headingLevel,
            bool showButtons)
            : base(
                page,
                "zone '" + debugRegion.Name + "'",
                headingLevel)
        {
            CssClass = "region";

            string repeat = null;

            if (!ReferenceEquals(debugRegion.RepeatType, null))
            {
                repeat = debugRegion.RepeatType.DisplayName(TypeExtensions.NamespaceOption.None);

                if (!string.IsNullOrEmpty(debugRegion.RepeatScope))
                {
                    repeat = "'" + debugRegion.RepeatScope + "' " + repeat;
                }

                if (!string.IsNullOrEmpty(debugRegion.ListScope))
                {
                    repeat += " from a list in '" + debugRegion.ListScope + "' scope";
                }

                repeat = "Repeat for each " + repeat;

                if (showButtons)
                {
                    AddChild(new TextDrawing {
                        Text = new[] { repeat }
                    });
                }
            }

            var details = new List <string>();

            if (!string.IsNullOrEmpty(repeat))
            {
                details.Add(repeat);
            }
            AddDebugInfo(details, debugRegion);

            if (details.Count > 0)
            {
                if (showButtons)
                {
                    AddDetails(details, AddHeaderButton(page, "Detail"));
                }
                else
                {
                    AddDetails(details, this);
                }
            }

            if (!ReferenceEquals(debugRegion.Scope, null) && debugRegion.Scope.HasData())
            {
                var dataScopeDrawing = new DataScopeRulesDrawing(
                    drawing,
                    page,
                    debugRegion.Scope,
                    headingLevel + 1,
                    false,
                    0);

                if (showButtons)
                {
                    AddHeaderButton(page, "Scope").AddChild(dataScopeDrawing);
                }
                else
                {
                    AddChild(dataScopeDrawing);
                }
            }

            if (!ReferenceEquals(debugRegion.DataContext, null) && debugRegion.DataContext.HasData())
            {
                var dataScopeDrawing = new DataScopeRulesDrawing(
                    drawing,
                    page,
                    debugRegion.DataContext,
                    headingLevel + 1,
                    false,
                    0);

                if (showButtons)
                {
                    AddHeaderButton(page, "Context").AddChild(dataScopeDrawing);
                }
                else
                {
                    AddChild(dataScopeDrawing);
                }
            }

            if (showButtons && !ReferenceEquals(debugRegion.Element, null))
            {
                var elementDebugInfo = debugRegion.Element.GetDebugInfo <DebugRegion>();
                if (elementDebugInfo != null && elementDebugInfo.HasData())
                {
                    AddHeaderButton(page, "Definition")
                    .AddChild(new RegionDrawing(
                                  drawing,
                                  page,
                                  elementDebugInfo,
                                  headingLevel + 1,
                                  false));
                }
            }

            if (debugRegion.Children != null &&
                debugRegion.Children.Count > 0 &&
                debugRegion.Children[0] != null &&
                debugRegion.Children[0].HasData())
            {
                var content = drawing.DrawDebugInfo(page, debugRegion.Children[0], headingLevel, showButtons);
                AddChild(content);
            }
        }