Esempio n. 1
0
        public void TestCreateStatusRouteValueValueNotMatchOk()
        {
            //SETUP
            var status       = new GenericBizRunner.StatusGenericHandler();
            var controller   = new ToDoController();
            var dto          = new CreateTodoDto();
            var actionResult = status.Response(controller, "Get", new { id = 999 }, dto);

            //ATTEMPT
            var statusCode = actionResult.GetStatusCode();
            var rStatus    = actionResult.CheckCreateResponse("Get", new { id = 7 }, dto);

            //VERIFY
            statusCode.ShouldEqual(CreateResponse.CreatedStatusCode);
            rStatus.IsValid.ShouldBeFalse(rStatus.GetAllErrors());
            rStatus.GetAllErrors().ShouldEqual("RouteValues->id, different values: expected = 7, found = 999");
        }
Esempio n. 2
0
        public void TestCreateStatusBadDtoOk()
        {
            //SETUP
            var status       = new GenericBizRunner.StatusGenericHandler();
            var controller   = new ToDoController();
            var dto          = new CreateTodoDto();
            var actionResult = status.Response(controller, "Get", new { id = 7 }, dto);

            //ATTEMPT
            var statusCode = actionResult.GetStatusCode();
            var rStatus    = actionResult.CheckCreateResponse("Get", new { id = 7 }, new CreateTodoDto());

            //VERIFY
            statusCode.ShouldEqual(CreateResponse.CreatedStatusCode);
            rStatus.IsValid.ShouldBeFalse(rStatus.GetAllErrors());
            rStatus.GetAllErrors().ShouldEqual("DTO: the returned DTO instance does not match the test DTO: expected CreateTodoDto, found: CreateTodoDto");
        }
Esempio n. 3
0
        public void TestCreateStatusOk()
        {
            //SETUP
            var status       = new GenericBizRunner.StatusGenericHandler();
            var controller   = new ToDoController();
            var dto          = new CreateTodoDto();
            var actionResult = status.Response(controller, "Get", new { id = 7 }, dto);

            //ATTEMPT
            var statusCode = actionResult.GetStatusCode();
            var rStatus    = actionResult.CheckCreateResponse("Get", new { id = 7 }, dto);

            //VERIFY
            statusCode.ShouldEqual(CreateResponse.CreatedStatusCode);
            rStatus.IsValid.ShouldBeTrue(rStatus.GetAllErrors());
            rStatus.Message.ShouldEqual("Success");
        }
Esempio n. 4
0
        public void TestCreateStatusBadRouteNameOk()
        {
            //SETUP
            var status       = new GenericBizRunner.StatusGenericHandler();
            var controller   = new ToDoController();
            var dto          = new CreateTodoDto();
            var actionResult = status.Response(controller, "Bad", new { id = 7 }, dto);

            //ATTEMPT
            var statusCode = actionResult.GetStatusCode();
            var rStatus    = actionResult.CheckCreateResponse("Get", new { id = 7 }, dto);

            //VERIFY
            statusCode.ShouldEqual(CreateResponse.CreatedStatusCode);
            rStatus.IsValid.ShouldBeFalse(rStatus.GetAllErrors());
            rStatus.GetAllErrors().ShouldEqual("RouteName: expected Get, found: Bad");
        }
Esempio n. 5
0
        public static GenericBizRunner.IStatusGeneric <Order> CreateOrderViaBizLogic(string customerName,
                                                                                     IEnumerable <OrderBooksDto> bookOrders)
        {
            var status = new GenericBizRunner.StatusGenericHandler <Order>();
            var order  = new Order
            {
                CustomerName = customerName,
                Status       = OrderStatuses.Created,
                OrderedUtc   = DateTime.UtcNow
            };

            status.Result = order;

            byte lineNum = 1;

            order._lineItems = new HashSet <LineItem>(bookOrders
                                                      .Select(x => new LineItem(x.numBooks, x.ChosenBook, lineNum++)));
            if (!order._lineItems.Any())
            {
                status.AddError("No items in your basket.");
            }
            return(status);
        }