public void ReadFromJson() { PhoneOrderEntity orderInstance; var factory = new PhoneOrderEntityFactory(); const String json = "{\"first_name\":\"John\",\"last_name\":\"Smith\"}"; factory.FromJson(json); orderInstance = factory.GetInstance(); Assert.AreEqual("John", orderInstance.FirstName); Assert.AreEqual("Smith", orderInstance.LastName); }
public String CreatePhoneOrder(Stream body) { String json = getJsonFromBody(body); ResponseDTO responseDTO = new ResponseDTO(); PhoneOrderEntity order; phoneOrderEntityFactory.FromJson(json); phoneOrderEntityFactory.GenerateId(); phoneOrderEntityFactory.GeneratePlacedOnDate(); phoneOrderEntityFactory.SetStatus(PhoneOrderEntity.ApprovalStatus.Open); order = phoneOrderEntityFactory.GetInstance(); phoneOrderRepository.InsertPhoneOrder(order); responseDTO.Result = "Done"; return(JsonConvert.SerializeObject(responseDTO)); }