public PartialViewResult Merge(string first, string second) { try { var firstArray = ConvertStringToIntArray(first); var secondArray = ConvertStringToIntArray(second); var result = _basicAlgorithms.Merge(firstArray, secondArray); return(PartialView( "_Results", new ResultsViewModel { Success = true, Result = result .Select(x => x.ToString()) .Aggregate((acc, next) => string.Format("{0}, {1}", acc, next)) })); } catch (Exception) { return(PartialView("_Results", new ResultsViewModel { Success = false })); } }
public void Merge_SeperableCollections_Merged() { var result = _basicAlgorithms.Merge(new int[] { 1, 2 }, new int[] { 3, 4 }); CollectionAssert.AreEqual(new[] { 1, 2, 3, 4 }, result.ToArray()); }