コード例 #1
0
 public void ReadsSingleCommandFromFile()
 {
     if (File.Exists(SingleCommandFilePath)) File.Delete(SingleCommandFilePath);
     var queue = new FileCommandQueueHandler(SingleCommandFilePath);
     Assert.IsEmpty(queue.GetCommands());
     File.WriteAllText(SingleCommandFilePath, JsonConvert.SerializeObject(new LiquidateCommand(), new JsonSerializerSettings{TypeNameHandling = TypeNameHandling.All}));
     Assert.IsInstanceOf(typeof (LiquidateCommand), queue.GetCommands().Single());
 }
コード例 #2
0
 public void ReadsMultipleCommandsFromFile()
 {
     if (File.Exists(MultiCommandFilePath)) File.Delete(MultiCommandFilePath);
     var queue = new FileCommandQueueHandler(MultiCommandFilePath);
     Assert.IsEmpty(queue.GetCommands());
     File.WriteAllText(MultiCommandFilePath, 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());
 }