public void ReadsSingleJsonCommandFromFile() { if (File.Exists(SingleCommandJsonFilePath)) File.Delete(SingleCommandJsonFilePath); var queue = new JsonCommandQueueHandler(SingleCommandJsonFilePath); Assert.IsEmpty(queue.GetCommands()); File.WriteAllText(SingleCommandJsonFilePath, JsonConvert.SerializeObject(new LiquidateCommand(), new JsonSerializerSettings{TypeNameHandling = TypeNameHandling.All})); Assert.IsInstanceOf(typeof (LiquidateCommand), queue.GetCommands().Single()); }
public void ReadsMultipleCommandsFromJsonFile() { if (File.Exists(MultiCommandJsonFilePath)) File.Delete(MultiCommandJsonFilePath); var queue = new JsonCommandQueueHandler(MultiCommandJsonFilePath); Assert.IsEmpty(queue.GetCommands()); File.WriteAllText(MultiCommandJsonFilePath, JsonConvert.SerializeObject(new List<ICommand> { new LiquidateCommand(), new SpecialCommand() }, new JsonSerializerSettings {TypeNameHandling = TypeNameHandling.All})); var list = queue.GetCommands().ToList(); Assert.IsInstanceOf(typeof (LiquidateCommand), list[0]); Assert.IsInstanceOf(typeof (SpecialCommand), list[1]); Assert.IsEmpty(queue.GetCommands()); }