public void TestCreateStatusWithErrorsOk() { //SETUP var status = new GenericBizRunner.StatusGenericHandler(); var controller = new ToDoController(); var dto = new CreateTodoDto(); status.AddError("An error"); 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.ErrorsStatusCode); rStatus.IsValid.ShouldBeTrue(rStatus.GetAllErrors()); rStatus.Message.ShouldEqual("Errors: An error"); }
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); }