public static void Main(string[] args) { //string fileToLoad = "drugfile_forparsing"; string fileToLoad = "input_BNF_ertapenem"; SetJsonConverter(); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); ParseCommand command = new ParseCommand(path + "\\" + fileToLoad + ".json"); DrugsInput parsedInput = command.Execute(); SerializeCommand serializeCommand = new SerializeCommand(parsedInput); string resultJson = serializeCommand.Execute(); WriteJsonToFile(resultJson); }
public void ValidDrugInput_Serialize_Success() { // Arrange IList <Drug> drugs = new List <Drug> { DrugFactory.GetDrug("testname1", "testIndication1", "testRoute"), DrugFactory.GetDrug("testname2", "testIndication2", "testRoute") }; DrugsInput input = new DrugsInput { Drugs = drugs }; SerializeCommand command = new SerializeCommand(input); // Act var result = command.Execute(); // Assert Assert.Contains("testname1", result); Assert.Contains("testIndication1", result); Assert.Contains("testname2", result); Assert.Contains("testIndication2", result); Assert.DoesNotContain("testRoute", result); Assert.Contains("TestRoute", result); }
/// <summary> /// Constructor. /// </summary> /// <param name="drugInput">Drug input object.</param> public SerializeCommand(DrugsInput drugInput) { input = drugInput; }
/// <summary> /// Start parsing the json string into object models. /// </summary> /// <param name="jsonInput">json string.</param> /// <returns>DrugsInput model</returns> public DrugsInput Deserialize(string jsonInput) { DrugsInput input = JsonConvert.DeserializeObject <DrugsInput>(jsonInput); return(input); }