public void Order_NotDistinct_OrderedNumbers() { //arrange var stubNumbers = new int[] { 5, 2, 8, 10, 1, 10, 5 }; var expectedNumbers = new int[] { 1, 2, 5, 5, 8, 10, 10 }; var service = new NumberOrderingService(stubNumbers); //act service.Order(); //assert CollectionAssert.AreEqual(expectedNumbers, service.Numbers); }
public void Order_BiggerThanTen_OrderedNumbers() { //arrange var stubNumbers = new int[] { 5, 2, 8, 11, 12 }; var expectedNumbers = new int[] { 2, 5, 8, 11, 12 }; var service = new NumberOrderingService(stubNumbers); //act service.Order(); //assert CollectionAssert.AreEqual(expectedNumbers, service.Numbers); }
public void Order_LessThanOne_OrderedNumbers() { //arrange var stubNumbers = new int[] { 5, -2, 8, 10, -1, 0 }; var expectedNumbers = new int[] { -2, -1, 0, 5, 8, 10 }; var service = new NumberOrderingService(stubNumbers); //act service.Order(); //assert CollectionAssert.AreEqual(expectedNumbers, service.Numbers); }
public async Task <IActionResult> Order([FromBody] int[] numbers) { if (numbers == null || !numbers.Any() || numbers.Any(n => n < 1) || numbers.Any(n => n > 10) || numbers.Length != numbers.Distinct().Count()) { return(new BadRequestResult()); } var service = new NumberOrderingService(numbers); service.Order(); await File.WriteAllTextAsync(resultPath, string.Join(",", service.Numbers)); return(new OkObjectResult(service.Numbers)); }
public void Order_EmptyArray_ArgumentException() { var stubNumbers = new int[] { }; var service = new NumberOrderingService(stubNumbers); }
public void Order_Null_ArgumentNullException() { var service = new NumberOrderingService(null); }