public void DeletePart_Success() { int[] testProductIds = new int[] { 1, 2, 3, 4, 5 }; int position = 5; Assert.AreEqual((arrayOperator.RemoveElementAt(position, testProductIds)).ToString(), (new int[] { 1, 2, 3, 4 }).ToString()); }
public ActionResult <string> DeletePart(int position, int[] productIds) { try { if (productIds != null && productIds.Count() > 0) { if (position > 0 && position - 1 < productIds.Count()) { ArrayOperator arrayOperator = new ArrayOperator(); return(Content($"[{string.Join(",", arrayOperator.RemoveElementAt(position, productIds))}]")); } else { return(Content($"[{string.Join(",", productIds)}]")); } } else { return(Content(string.Empty)); } } catch (Exception ex) { return(BadRequest("Sorry!An error occurred while deleting the productId!\nError: " + ex.Message)); } }