Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 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));
        }