public void MostCommon() { CM.Models.MyModels mm = new MyModels(); //Most Common int[] arrResult = new int[] { 4, 5 }; int[] arrIn = new int[] { 1, 2, 3, 4, 5, 5, 4 }; Assert.AreEqual(String.Join(",", arrResult), String.Join(",", mm.GetMostCommon(arrIn))); }
public ActionResult Index(FormCollection formdata) { try { CM.Models.MyModels mm = new MyModels(); //Last Data Element Contains our Button Name if (formdata[formdata.Count - 1] == "Check IsNullOrEmpty") { string s = formdata[0]; CM.Models.MyModels.ResultString = s.IsNullOrEmpty().ToString(); } else if (formdata[formdata.Count - 1] == "Show Positive Divisors") { CM.Models.MyModels.Input = int.Parse(formdata[0]); var iEnum = mm.GetDivisors(int.Parse(formdata[0])); CM.Models.MyModels.DivResultString = String.Join(",", iEnum); } else if (formdata[formdata.Count - 1] == "Calculate Area") { //Calc Triangle Area CM.Models.Triangle triangle = new CM.Models.Triangle(); CM.Models.Triangle.Side1 = (float)Convert.ToDecimal(formdata[0]); CM.Models.Triangle.Side2 = (float)Convert.ToDecimal(formdata[1]); CM.Models.Triangle.Side3 = (float)Convert.ToDecimal(formdata[2]); triangle.calcArea(); } else if (formdata[formdata.Count - 1] == "Show Most Common Numbers") { CM.Models.MyModels.InputArray = formdata[0]; IList<int> iList = new List<int>(); var sArray = formdata[0].Split(",".ToCharArray()); foreach (var newArrayItem in sArray) iList.Add(int.Parse(newArrayItem)); CM.Models.MyModels.ResultArray = String.Join(",",mm.GetMostCommon(iList.ToArray())); } } catch (Exception ex){//Catch all errors ViewBag.Exception = ex.Message; } return View(); }