Beispiel #1
0
 public ExportCommand(string fileName, Dataformat format, IStore store, ILogger logger, AppData data)
 {
     _filename = fileName;
     _format   = format;
     _store    = store;
     _logger   = logger;
     _data     = data;
 }
 public string AnyData(object obj, Dataformat format)
 {
     return(format switch
     {
         Dataformat.Normal => NormalData(obj),
         Dataformat.Xml => XmlData(obj),
         _ => "",
     });
Beispiel #3
0
        public async Task InvokeAsync_fileName_NULL_Expected_Result_0()
        {
            TestConsole console  = new TestConsole();
            Dataformat  format   = Dataformat.Json;
            string      fileName = null;

            ExportCommand command = new ExportCommand(fileName, format, _store, _logger, _data);

            var result = await command.InvAsync(console);

            Assert.AreEqual(0, result);
        }
Beispiel #4
0
        public async Task InvokeAsync_fileName_format_Expected_Result_1_and_File()
        {
            TestConsole console  = new TestConsole();
            Dataformat  format   = Dataformat.Json;
            string      fileName = "test_export";

            ExportCommand command = new ExportCommand(fileName, format, _store, _logger, _data);

            var result = await command.InvAsync(console);

            Assert.AreEqual(1, result);
            Assert.IsTrue(File.Exists("data/" + fileName + ".json"));
            File.Delete("data/" + fileName + ".json");
        }