public void CreateSelectForWithNoModelDoesNotSelectAnything()
 {
     var model = new SelectModelTest();
     var items = new SelectList(model.Countries, "Id", "Name");
     var tag = HtmlTagBuilder.CreateSelectFor<SelectModelTest, int>(m => m.SelectedCountryId, items);
     Assert.IsFalse(tag.Childs.Any(child => child.Attribute("selected") != null));
 }
 public void CreateSelectForDoesNotSelectAnythingByDefault()
 {
     var model = new SelectModelTest();
     var items = SelectList.CreateFrom(model.Countries, cm => cm.Id, cm => cm.Name);
     var tag = HtmlTagBuilder.CreateSelectFor(model, m => m.SelectedCountryId, items);
     Assert.IsFalse(tag.Childs.Any(child => child.Attribute("selected") != null));
 }
Exemplo n.º 3
0
        public void CtorSelectsElementIfSelectedValuePassed()
        {
            var model = new SelectModelTest();
            var list  = new SelectList(model.Countries, "Id", "Name", 2);

            Assert.IsTrue(list.Single(item => item.Selected).Value == 2.ToString());
        }
Exemplo n.º 4
0
        public void CtorDoesNotSelectsAnyElementIfSelectedValueIsNotFound()
        {
            var model = new SelectModelTest();
            var list  = new SelectList(model.Countries, "Id", "Name", 100);

            Assert.IsFalse(list.Any(item => item.Selected));
        }
Exemplo n.º 5
0
        public void CtorCreatesElementsUsingValuePropertyCorrecly()
        {
            var model = new SelectModelTest();
            var list  = new SelectList(model.Countries, "Id", "Name");

            Assert.AreEqual(model.Countries.Skip(1).First().Id.ToString(), list.Skip(1).First().Value);
        }
Exemplo n.º 6
0
        public void CtorCreatesElementsUsingTextPropertyCorrecly()
        {
            var model = new SelectModelTest();
            var list  = new SelectList(model.Countries, "Id", "Name");

            Assert.AreEqual(model.Countries.Skip(1).First().Name, list.Skip(1).First().Text);
        }
Exemplo n.º 7
0
        public void CtorDoesNotSelectAnyElementByDefault()
        {
            var model = new SelectModelTest();
            var list  = new SelectList(model.Countries, "Id", "Name");

            Assert.IsFalse(list.Any(item => item.Selected));
        }
Exemplo n.º 8
0
        public void CtorCreatesSameNumberOfElementsThanSource()
        {
            var model = new SelectModelTest();
            var list  = new SelectList(model.Countries, "Id", "Name");

            Assert.AreEqual(model.Countries.Count(), list.Count());
        }
Exemplo n.º 9
0
        public void CreateFromCreatesElementsUsingTextPropertyCorrecly()
        {
            var model = new SelectModelTest();
            var list  = SelectList.CreateFrom(model.Countries, cm => cm.Id, cm => cm.Name);

            Assert.AreEqual(model.Countries.Skip(1).First().Name, list.Skip(1).First().Text);
        }
Exemplo n.º 10
0
        public void CreateFromDoesNotSelectAnyElementByDefault()
        {
            var model = new SelectModelTest();
            var list  = SelectList.CreateFrom(model.Countries, cm => cm.Id, cm => cm.Name);

            Assert.IsFalse(list.Any(item => item.Selected));
        }
Exemplo n.º 11
0
        public void CreateFromCreatesSameNumberOfElementsThanSource()
        {
            var model = new SelectModelTest();
            var list  = SelectList.CreateFrom(model.Countries, cm => cm.Id, cm => cm.Name);

            Assert.AreEqual(model.Countries.Count(), list.Count());
        }
 public void CreateSelectForWithNoModelSelectsItemBasedOnSelectList()
 {
     var model = new SelectModelTest();
     var items = new SelectList(model.Countries, "Id", "Name", 2);
     var tag = HtmlTagBuilder.CreateSelectFor<SelectModelTest, int>(m => m.SelectedCountryId, items);
     Assert.AreEqual(2.ToString(), tag.Childs.Single(child => 
         child.Attribute("selected") != null).Attribute("value").Value);
 }
 public void CreateSelectForSelectsItemBasedOnSelectList()
 {
     var model = new SelectModelTest();
     var items = SelectList.CreateFrom(model.Countries, cm => cm.Id, cm => cm.Name);
     items.Last().Selected = true;
     var tag = HtmlTagBuilder.CreateSelectFor(model, m => m.SelectedCountryId, items);
     var child = tag.Childs.Single(c => c.Attribute("selected") != null);
     Assert.AreEqual(items.Last().Value, child.Attribute("value").Value);
 }