public IHttpActionResult Get(int index, int num)
        {
            var             orders    = new OrderList(this.orderRepository);
            List <OrderDto> orderList = orders.GetOrdersList(index, num);

            return(Ok <IEnumerable <OrderDto> >(orderList));
        }
        public void GetOrdersList_IndexMoreThanRangeNumIsNotZero_ReturnsZeroOrders()
        {
            var mock = new Mock <IOrderRepository>();
            int index = 4, num = 5;

            mock.Setup(moq => moq.GetList(null)).Returns(new List <Order>());
            OrderList orderList = new OrderList(mock.Object);
            int       expected  = 0;

            int actual = orderList.GetOrdersList(index, num).Count;

            Assert.AreEqual(expected, actual);
        }
        public void GetOrdersList_IndexAndNumIsZero_ReturnsNumOrdersBeginsFromIndex()
        {
            var mock = new Mock <IOrderRepository>();
            int index = 0, num = 0;

            mock.Setup(moq => moq.GetList(null)).Returns(new List <Order>());
            OrderList orderList = new OrderList(mock.Object);
            int       expected  = num;

            int actual = orderList.GetOrdersList(index, num).Count;

            Assert.AreEqual(expected, actual);
        }
        public void GetOrdersList_IndexNotZeroInRangeNumNotZeroMoreThanRange_ReturnsMoreThanZeroAndLessThanNumOrders()
        {
            var mock = new Mock <IOrderRepository>();
            int index = 4, num = 5;

            mock.Setup(moq => moq.GetList(null)).Returns(new List <Order>()
            {
                new Order(new Guid(), 1, new Contact(), new User("john", "*****@*****.**")),
                new Order(new Guid(), 2, new Contact(), new User("john", "*****@*****.**")),
                new Order(new Guid(), 3, new Contact(), new User("john", "*****@*****.**")),
                new Order(new Guid(), 4, new Contact(), new User("john", "*****@*****.**")),
                new Order(new Guid(), 5, new Contact(), new User("john", "*****@*****.**"))
            });
            OrderList orderList = new OrderList(mock.Object);
            int       expected  = num;

            int actual = orderList.GetOrdersList(index, num).Count;

            Assert.IsTrue(actual < expected);
        }
        public void GetOrdersList_IndexAndNumIsNotZeroAndAreInRange_ReturnsNumOrdersBeginsFromIndex()
        {
            var mock = new Mock <IOrderRepository>();
            int index = 1, num = 4;

            mock.Setup(moq => moq.GetList(null)).Returns(new List <Order>()
            {
                new Order(new Guid(), 1, new Contact(), new User("john", "*****@*****.**")),
                new Order(new Guid(), 2, new Contact(), new User("john", "*****@*****.**")),
                new Order(new Guid(), 3, new Contact(), new User("john", "*****@*****.**")),
                new Order(new Guid(), 4, new Contact(), new User("john", "*****@*****.**")),
                new Order(new Guid(), 5, new Contact(), new User("john", "*****@*****.**"))
            });
            OrderList orderList = new OrderList(mock.Object);
            int       expected  = num;

            int actual = orderList.GetOrdersList(index, num).Count;

            Assert.AreEqual(expected, actual);
        }