Esempio n. 1
0
        public void OhmCalc_GetDefinedColors_Test()
        {
            var cbi     = new Models.ColorBandData();
            var cbiList = cbi.ColorBandItems;

            Assert.IsTrue(cbiList.Count == 13);     // 12 colors + "None" option
        }
Esempio n. 2
0
        public IActionResult Index()
        {
            var bdc    = new Models.ColorBandData();
            var result = new ViewResult();
            List <SelectListItem> list       = new List <SelectListItem>();
            List <SelectListItem> listNoNone = new List <SelectListItem>();

            foreach (var itm in bdc.ColorBandItems)
            {
                if (!string.IsNullOrEmpty(itm.ColorName))
                {
                    listNoNone.Add(new SelectListItem()
                    {
                        Text = itm.DisplayName, Value = itm.ColorName
                    });
                }
                list.Add(new SelectListItem()
                {
                    Text = itm.DisplayName, Value = itm.ColorName
                });
            }
            var colorBandItems = new ViewModel.ViewItems()
            {
                BandAItems = new SelectList(listNoNone, "Value", "Text"),
                BandBItems = new SelectList(listNoNone, "Value", "Text"),
                BandCItems = new SelectList(listNoNone, "Value", "Text"),
                BandDItems = new SelectList(list, "Value", "Text"),
            };

            ViewData.Model = colorBandItems;
            return(View());
        }