Tester for System.Web.UI.WebControls.Repeater. Generally, you don't test through this tester. Instead, you use the Item method to use as a container for testing controls that are inside the repeater. The ItemCount method may also be useful. This example demonstrates how to test a button that's in the third item of a repeater: RepeaterTester repeater = new RepeaterTester("repeater"); ButtonTester button = new ButtonTester("button", repeater.Item(2));
Наследование: NamingContainerTester
Пример #1
0
 public void TestAllTemplates()
 {
     RepeaterTester all = new RepeaterTester("allRepeater", true, true, true);
     AssertFiveThings(all, "allLabel");
     AssertFourSeparators(all, "allSeparatorTemplateLabel");
     Assert.AreEqual("header", new LabelTester("allHeaderTemplateLabel", all.Header).Text);
     Assert.AreEqual("footer", new LabelTester("allFooterTemplateLabel", all.Footer).Text);
 }
Пример #2
0
 private static string GetMessage(string aspId, RepeaterTester repeater) 
 {
   return String.Format(
     "Tester '{0}' has RepeaterTester '{1}' as its container. That isn't allowed. "
     + "It should be a RepeaterTester.RepeaterTemplateTester.  "
     + "When constructing {0}, pass '{1}.Item(#)', '{1}.Header', '{1}.Footer', "
     + "or '{1}.GetSeparator(#)' as the container argument.",
     aspId, repeater.AspId);
 }
Пример #3
0
        public void TestDescriptions()
        {
            RepeaterTester all = new RepeaterTester("allRepeater", true, true, true);

            AssertDescription("RepeaterTester 'allRepeater'", all);
            AssertDescription("HeaderTemplate in RepeaterTester 'allRepeater'", all.Header);
            AssertDescription("Item #3 in RepeaterTester 'allRepeater'", all.Item(2));
            AssertDescription("Separator #2 in RepeaterTester 'allRepeater'", all.Separator(1));
            AssertDescription("FooterTemplate in RepeaterTester 'allRepeater'", all.Footer);
        }
Пример #4
0
 public void TestAlternatingItemTemplate()
 {
     RepeaterTester alternating = new RepeaterTester("alternatingRepeater");
     AssertFiveThings(alternating, "alternatingLabel");
 }
Пример #5
0
 private void AssertFourSeparators(RepeaterTester tester, string separatorLabelId)
 {
     Assert.AreEqual(" | ", new LabelTester(separatorLabelId, tester.Separator(0)).Text);
     Assert.AreEqual(" | ", new LabelTester(separatorLabelId, tester.Separator(1)).Text);
     Assert.AreEqual(" | ", new LabelTester(separatorLabelId, tester.Separator(2)).Text);
     Assert.AreEqual(" | ", new LabelTester(separatorLabelId, tester.Separator(3)).Text);
 }
Пример #6
0
 /// <summary>
 /// Create a tester for a specific item in a repeater.
 /// </summary>
 /// <param name="itemNum">The item number to test (zero-based).</param>
 /// <param name="container">The repeater tester this item is contained
 /// within.</param>
 public RepeaterItemTester(int itemNum, RepeaterTester container) : base(container)
 {
   this.container = container;
   this.itemNum = itemNum;
 }
Пример #7
0
 /// <summary>
 /// Create a tester for a specific item in a repeater.
 /// </summary>
 /// <param name="separatorNum">The index of the separator to test (zero-based).</param>
 /// <param name="container">The repeater tester this item is contained
 /// within.</param>
 public RepeaterSeparatorTester(int separatorNum, RepeaterTester container)
     : base(container)
 {
     this.container = container;
     this.separatorNum = separatorNum;
 }
Пример #8
0
 /// <summary>
 /// Create a tester for a repeater's HeaderTemplate.
 /// </summary>
 /// <param name="container">The repeater tester that contains this HeaderTemplate</param>
 public RepeaterHeaderTester(RepeaterTester container)
     : base(container)
 {
     this.container = container;
 }
Пример #9
0
        public void TestNestedRepeater()
        {
            RepeaterTester innerRepeater1 = new RepeaterTester("innerRepeater1", repeater1.Item(0));
            RepeaterTester innerRepeater2 = new RepeaterTester("innerRepeater1", repeater1.Item(1));

            Assert.AreEqual(2, innerRepeater1.ItemCount);
            Assert.AreEqual(4, innerRepeater2.ItemCount);
        }
Пример #10
0
 public void TestHeaderTemplate()
 {
     RepeaterTester header = new RepeaterTester("headerRepeater", true, false, false);
     AssertFiveThings(header, "headerLabel");
     Assert.AreEqual("header", new LabelTester("nestedHeaderLabel", header.Header).Text);
 }
Пример #11
0
 public void TestFooterTemplate()
 {
     RepeaterTester footer = new RepeaterTester("footerRepeater", false, false, true);
     AssertFiveThings(footer, "footerLabel");
     Assert.AreEqual("footer", new LabelTester("nestedFooterLabel", footer.Footer).Text);
 }
Пример #12
0
 internal ContainerMustBeItemException(string aspId, RepeaterTester repeater) 
   : base(GetMessage(aspId, repeater))
 {
 }
Пример #13
0
 /// <summary>
 /// Create a tester for a specific item in a repeater.
 /// </summary>
 /// <param name="container">The repeater tester this item is contained
 /// within.</param>
 public RepeaterFooterTester(RepeaterTester container) : base(container)
 {
   this.container = container;
 }
Пример #14
0
 /// <summary>
 /// Create a tester for a specific item in a repeater.
 /// </summary>
 /// <param name="separatorNum">The index of the separator to test (zero-based).</param>
 /// <param name="container">The repeater tester this item is contained
 /// within.</param>
 public RepeaterSeparatorTester(int separatorNum, RepeaterTester container) : base(container)
 {
   this.container = container;
   this.separatorNum = separatorNum;
 }
Пример #15
0
 internal ContainerMustBeItemException(string aspId, RepeaterTester repeater)
     : base(GetMessage(aspId, repeater))
 {
 }
Пример #16
0
 public void TestSeparatorTemplate()
 {
     RepeaterTester separator = new RepeaterTester("separatorRepeater", false, true, false);
     AssertFiveThings(separator, "separatorLabel");
     AssertFourSeparators(separator, "nestedSeparatorLabel");
 }
Пример #17
0
 private static string GetMessage(string aspId, RepeaterTester repeater)
 {
     return String.Format(
       "Tester '{0}' has RepeaterTester '{1}' as its container. That isn't allowed. "
       + "It should be a RepeaterTester.RepeaterTemplateTester.  "
       + "When constructing {0}, pass '{1}.Item(#)', '{1}.Header', '{1}.Footer', "
       + "or '{1}.GetSeparator(#)' as the container argument.",
       aspId, repeater.AspId);
 }
Пример #18
0
        protected override void SetUp()
        {
            base.SetUp();

            repeater1 = new RepeaterTester("Repeater1", CurrentWebForm);
            repeater2 = new RepeaterTester("Repeater2", CurrentWebForm);
            repeater3 = new RepeaterTester("Repeater3", CurrentWebForm);

            Browser.GetPage(BaseUrl + "/AspTester/RepeaterTestPage.aspx");
        }
Пример #19
0
 /// <summary>
 /// Create a tester for a specific item in a repeater.
 /// </summary>
 /// <param name="itemNum">The item number to test (zero-based).</param>
 /// <param name="container">The repeater tester this item is contained
 /// within.</param>
 public RepeaterItemTester(int itemNum, RepeaterTester container)
     : base(container)
 {
     this.container = container;
     this.itemNum = itemNum;
 }
Пример #20
0
 private void AssertFiveThings(RepeaterTester tester, string labelId)
 {
     Assert.AreEqual(5, tester.ItemCount);
     Assert.AreEqual("one", new LabelTester(labelId, tester.Item(0)).Text);
     Assert.AreEqual("two", new LabelTester(labelId, tester.Item(1)).Text);
     Assert.AreEqual("three", new LabelTester(labelId, tester.Item(2)).Text);
     Assert.AreEqual("four", new LabelTester(labelId, tester.Item(3)).Text);
     Assert.AreEqual("five", new LabelTester(labelId, tester.Item(4)).Text);
 }
Пример #21
0
 /// <summary>
 /// Create a tester for a specific template in a repeater.
 /// </summary>
 /// <param name="container">The repeater tester this item is contained
 /// within.</param>
 public RepeaterTemplateTester(RepeaterTester container)
     : base(null, container)
 {
 }
Пример #22
0
 /// <summary>
 /// Create a tester for a specific template in a repeater.
 /// </summary>
 /// <param name="container">The repeater tester this item is contained
 /// within.</param>
 public RepeaterTemplateTester(RepeaterTester container) : base(null, container)
 {
 }