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 GetAllRecords() { PhoneOrderService phoneOrderService = new PhoneOrderService(); List <PhoneOrderEntity> orders = new List <PhoneOrderEntity>(); PhoneOrderEntityFactory phoneOrderEntityFactory = new PhoneOrderEntityFactory(); Mock <PhoneOrderRepository> mockPhoneOrderRepository = mockFactory.CreateMock <PhoneOrderRepository>(); const String expectedResult = "{\"result\":\"Done\",\"count\":0,\"orders\":[{\"first_name\":\"John\",\"last_name\":\"Smith\"," + "\"street\":null,\"city\":null,\"zipcode\":0,\"phone_number\":null,\"status\":0,\"id\":\"00000000-0000-0000-0000-000000000000\"," + "\"placed_on\":\"0001-01-01T00:00:00\"}]}"; phoneOrderEntityFactory.SetName("John", "Smith"); orders.Add(phoneOrderEntityFactory.GetInstance()); mockPhoneOrderRepository.Expects.One.Method(x => x.GetOrderList()).WillReturn(orders); phoneOrderService.SetPrivateField("phoneOrderRepository", mockPhoneOrderRepository.MockObject); String response = phoneOrderService.GetAllRecords(); Assert.AreEqual(expectedResult, response); }