public PhoneOrderMethods() : base("/PhoneOrder") { Post["/createDefault", true] = async(_, token) => { await Task.Delay(50); logger.Info("Create default Order"); return(phoneOrderService.CreateDefaultOrder()); }; Post["/count", true] = async(_, token) => { await Task.Delay(50); logger.Info("Get Count"); return(phoneOrderService.GetRecordCount()); }; Post["/listAll", true] = async(_, token) => { await Task.Delay(50); logger.Info("List All"); return(phoneOrderService.GetAllRecords()); }; Post["/reset", true] = async(_, token) => { await Task.Delay(50); logger.Info("reset"); return(phoneOrderService.ResetRecords()); }; Post["/addOrder", true] = async(_, token) => { await Task.Delay(50); logger.Info("add order"); return(phoneOrderService.CreatePhoneOrder(this.Request.Body)); }; Post["/updateStatus", true] = async(_, token) => { await Task.Delay(50); logger.Info("Update Status"); return(phoneOrderService.UpdateOrderStatus(this.Request.Body)); }; }
public void UpdateOrderStatusFailed() { PhoneOrderService phoneOrderService = new PhoneOrderService(); PhoneOrderEntity phoneOrderEntityFromFactory = new PhoneOrderEntity(); MemoryStream ms = new MemoryStream(); StreamWriter sw = new StreamWriter(ms); String response; Mock <PhoneOrderRepository> mockPhoneOrderRepository = mockFactory.CreateMock <PhoneOrderRepository>(); mockPhoneOrderRepository.Expects.One.Method(x => x.UpdateStatus(null)).WithAnyArguments().WillReturn(false); phoneOrderService.SetPrivateField("phoneOrderRepository", mockPhoneOrderRepository.MockObject); sw.Write("{\"status\":1, \"id\":\"00000000-0000-0000-0000-000000000000\"}"); sw.Flush(); ms.Position = 0; response = phoneOrderService.UpdateOrderStatus(ms); sw.Close(); ms.Close(); Assert.AreEqual("{\"result\":\"Incomplete\",\"count\":0,\"orders\":null}", response); }