예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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));
        }
예제 #5
0
 public void Order_EmptyArray_ArgumentException()
 {
     var stubNumbers = new int[] { };
     var service     = new NumberOrderingService(stubNumbers);
 }
예제 #6
0
 public void Order_Null_ArgumentNullException()
 {
     var service = new NumberOrderingService(null);
 }