public void radio_set_renders_in_a_div()
        {
            var html    = new RadioSet("foo.Bar").ToString();
            var element = html.ShouldHaveHtmlNode("foo_Bar");

            element.ShouldBeNamed(HtmlTag.Div).ShouldHaveChildNodesCount(0);
        }
Beispiel #2
0
 public void radio_renders_selected_item_as_checked()
 {
     var html = new RadioSet("foo.Bar").Options<FakeEnum>().Selected(FakeEnum.Zero).ToString();
     var element = html.ShouldHaveHtmlNode("foo_Bar");
     var firstRadio = element.ShouldBeNamed(HtmlTag.Div).ShouldHaveChildNodesCount(8)[0];
     firstRadio.ShouldHaveAttribute(HtmlAttribute.Checked).WithValue(HtmlAttribute.Checked);
 }
        public void radio_renders_selected_item_as_checked()
        {
            var html       = new RadioSet("foo.Bar").Options <FakeEnum>().Selected(FakeEnum.Zero).ToString();
            var element    = html.ShouldHaveHtmlNode("foo_Bar");
            var firstRadio = element.ShouldBeNamed(HtmlTag.Div).ShouldHaveChildNodesCount(8)[0];

            firstRadio.ShouldHaveAttribute(HtmlAttribute.Checked).WithValue(HtmlAttribute.Checked);
        }
        	public void can_generate_radio_set_from_subset_of_enum()
        	{
            		var html = new RadioSet("foo.Bar").Options(new []{FakeEnum.One,FakeEnum.Two,FakeEnum.Three}).Selected(FakeEnum.Three).ToString();
            		var element = html.ShouldHaveHtmlNode("foo_Bar");
            		var options = element.ShouldHaveChildNodesCount(6);

            		VerifyOption("foo.Bar", (int)FakeEnum.One, FakeEnum.One, options[0], options[1], false);
            		VerifyOption("foo.Bar", (int)FakeEnum.Two, FakeEnum.Two, options[2], options[3], false);
            		VerifyOption("foo.Bar", (int)FakeEnum.Three, FakeEnum.Three, options[4], options[5], true);
        	}
        public void can_generate_radio_set_from_subset_of_enum()
        {
            var html    = new RadioSet("foo.Bar").Options(new [] { FakeEnum.One, FakeEnum.Two, FakeEnum.Three }).Selected(FakeEnum.Three).ToString();
            var element = html.ShouldHaveHtmlNode("foo_Bar");
            var options = element.ShouldHaveChildNodesCount(6);

            VerifyOption("foo.Bar", (int)FakeEnum.One, FakeEnum.One, options[0], options[1], false);
            VerifyOption("foo.Bar", (int)FakeEnum.Two, FakeEnum.Two, options[2], options[3], false);
            VerifyOption("foo.Bar", (int)FakeEnum.Three, FakeEnum.Three, options[4], options[5], true);
        }
Beispiel #6
0
        public void can_generate_radio_set_from_enum()
        {
            var html = new RadioSet("foo.Bar").Options<FakeEnum>().ToString();
            var element = html.ShouldHaveHtmlNode("foo_Bar");
            var options = element.ShouldHaveChildNodesCount(8);

            VerifyOption("foo.Bar", (int)FakeEnum.Zero, FakeEnum.Zero, options[0], options[1]);
            VerifyOption("foo.Bar", (int)FakeEnum.One, FakeEnum.One, options[2], options[3]);
            VerifyOption("foo.Bar", (int)FakeEnum.Two, FakeEnum.Two, options[4], options[5]);
            VerifyOption("foo.Bar", (int)FakeEnum.Three, FakeEnum.Three, options[6], options[7]);
        }
Beispiel #7
0
 public void can_specify_item_class_for_radio_set()
 {
     var cssClass = "highClass";
     var html = new RadioSet("foo.Bar").Options<FakeEnum>().ItemClass(cssClass).ToString();
     var element = html.ShouldHaveHtmlNode("foo_Bar");
     var nodes = element.ShouldHaveChildNodesCount(8);
     foreach (var node in nodes)
     {
         node.ShouldHaveAttribute(HtmlAttribute.Class).WithValue(cssClass);
     }
 }
Beispiel #8
0
 public void can_specify_option_format_for_radio_set()
 {
     var html = new RadioSet("foo.Bar").Options<FakeEnum>().ItemFormat("{0}<br/>").ToString();
     var element = html.ShouldHaveHtmlNode("foo_Bar");
     var nodes = element.ShouldHaveChildNodesCount(12);
     var brName = "br";
     nodes[2].ShouldBeNamed(brName);
     nodes[5].ShouldBeNamed(brName);
     nodes[8].ShouldBeNamed(brName);
     nodes[11].ShouldBeNamed(brName);
 }
        public void can_specify_item_class_for_radio_set()
        {
            var cssClass = "highClass";
            var html     = new RadioSet("foo.Bar").Options <FakeEnum>().ItemClass(cssClass).ToString();
            var element  = html.ShouldHaveHtmlNode("foo_Bar");
            var nodes    = element.ShouldHaveChildNodesCount(8);

            foreach (var node in nodes)
            {
                node.ShouldHaveAttribute(HtmlAttribute.Class).WithValue(cssClass);
            }
        }
        public void can_specify_option_format_for_radio_set()
        {
            var html    = new RadioSet("foo.Bar").Options <FakeEnum>().ItemFormat("{0}<br/>").ToString();
            var element = html.ShouldHaveHtmlNode("foo_Bar");
            var nodes   = element.ShouldHaveChildNodesCount(12);
            var brName  = "br";

            nodes[2].ShouldBeNamed(brName);
            nodes[5].ShouldBeNamed(brName);
            nodes[8].ShouldBeNamed(brName);
            nodes[11].ShouldBeNamed(brName);
        }
Beispiel #11
0
        public void can_generate_radio_set_from_model_choices()
        {
            var items = new List<FakeModel>
            {
                new FakeModel { Price = 1, Title = "One" },
                new FakeModel { Price = 2, Title = "Two" },
            };
            var html = new RadioSet("foo.Bar").Options(items, x => x.Price, x => x.Title).ToString();
            var element = html.ShouldHaveHtmlNode("foo_Bar");
            var options = element.ShouldHaveChildNodesCount(4);

            VerifyOption("foo.Bar", items[0].Price, items[0].Title, options[0], options[1]);
            VerifyOption("foo.Bar", items[1].Price, items[1].Title, options[2], options[3]);
        }
Beispiel #12
0
        public void can_modify_each_radio_button_element_using_the_option_data_item()
        {
            var items = new List<FakeModel>
            {
                new FakeModel { Price = 11, Title = "One" },
                new FakeModel { Price = 22, Title = "Two", Done = true },
            };
            const string name = "foo";
            var html = new RadioSet(name).Options(items, x => x.Price, x => x.Title)
                .EachOption((cb, opt, i) => cb.Disabled(((FakeModel)opt).Done)).ToString();
            var element = html.ShouldHaveHtmlNode(name);

            GetRadioButton(element, name, 11).ShouldNotHaveAttribute("disabled");
            GetRadioButton(element, name, 22).ShouldHaveAttribute("disabled");
        }
        public void restore_checked_from_radio_set()
        {
            stateDictionary.Add("Selection", new ModelState {
                Value = new ValueProviderResult((int)FakeEnum.Two, "2", CultureInfo.CurrentCulture)
            });
            expression = x => x.Selection;

            var html = new RadioSet(expression.GetNameFor(), expression.GetMemberExpression(), new List <IBehaviorMarker> {
                target
            }).Options <FakeEnum>().ToString();
            var element = html.ShouldHaveHtmlNode("Selection");
            var options = element.ShouldHaveChildNodesCount(8);

            RadioSetTests.VerifyOption("Selection", (int)FakeEnum.Zero, FakeEnum.Zero, options[0], options[1], false);
            RadioSetTests.VerifyOption("Selection", (int)FakeEnum.One, FakeEnum.One, options[2], options[3], false);
            RadioSetTests.VerifyOption("Selection", (int)FakeEnum.Two, FakeEnum.Two, options[4], options[5], true);
            RadioSetTests.VerifyOption("Selection", (int)FakeEnum.Three, FakeEnum.Three, options[6], options[7], false);
        }
        public void can_generate_radio_set_from_model_choices()
        {
            var items = new List <FakeModel>
            {
                new FakeModel {
                    Price = 1, Title = "One"
                },
                new FakeModel {
                    Price = 2, Title = "Two"
                },
            };
            var html    = new RadioSet("foo.Bar").Options(items, x => x.Price, x => x.Title).ToString();
            var element = html.ShouldHaveHtmlNode("foo_Bar");
            var options = element.ShouldHaveChildNodesCount(4);

            VerifyOption("foo.Bar", items[0].Price, items[0].Title, options[0], options[1], false);
            VerifyOption("foo.Bar", items[1].Price, items[1].Title, options[2], options[3], false);
        }
        public void can_modify_each_radio_button_element_using_the_option_data_item()
        {
            var items = new List <FakeModel>
            {
                new FakeModel {
                    Price = 11, Title = "One"
                },
                new FakeModel {
                    Price = 22, Title = "Two", Done = true
                },
            };
            const string name = "foo";
            var          html = new RadioSet(name).Options(items, x => x.Price, x => x.Title)
                                .EachOption((cb, opt, i) => cb.Disabled(((FakeModel)opt).Done)).ToString();
            var element = html.ShouldHaveHtmlNode(name);

            GetRadioButton(element, name, 11).ShouldNotHaveAttribute("disabled");
            GetRadioButton(element, name, 22).ShouldHaveAttribute("disabled");
        }
Beispiel #16
0
 public void radio_set_renders_in_a_div()
 {
     var html = new RadioSet("foo.Bar").ToString();
     var element = html.ShouldHaveHtmlNode("foo_Bar");
     element.ShouldBeNamed(HtmlTag.Div).ShouldHaveChildNodesCount(0);
 }
		public override IElement CreateHtmlElement()
		{
			RadioSet radioSet = new RadioSet(ElementID).Options(base.Options, x => x.ID, x => x.Title);

			return new Literal("").Html(radioSet.ToString()).Class("alternatives");
		}
        public void restore_checked_from_radio_set()
        {
            stateDictionary.Add("Selection", new ModelState { Value = new ValueProviderResult((int)FakeEnum.Two, "2", CultureInfo.CurrentCulture) });
            var target = new ValidationBehavior(() => stateDictionary);
            expression = x => x.Selection;

            var html = new RadioSet(expression.GetNameFor(), expression.GetMemberExpression(), new List<IBehaviorMarker> { target }).Options<FakeEnum>().ToString();
            var element = html.ShouldHaveHtmlNode("Selection");
            var options = element.ShouldHaveChildNodesCount(8);

            RadioSetTests.VerifyOption("Selection", (int)FakeEnum.Zero, FakeEnum.Zero, options[0], options[1],false);
            RadioSetTests.VerifyOption("Selection", (int)FakeEnum.One, FakeEnum.One, options[2], options[3],false);
            RadioSetTests.VerifyOption("Selection", (int)FakeEnum.Two, FakeEnum.Two, options[4], options[5],true);
            RadioSetTests.VerifyOption("Selection", (int)FakeEnum.Three, FakeEnum.Three, options[6], options[7],false);
        }
 void UserRadio(RadioSet radioSet)
 {
     radioSet.UseRadio(playerInventory.GetObjectiveTags());
     CollisionInteraction?.Invoke(null);
 }