Beispiel #1
0
        public async Task WriteFileTo(DirectoryInfo directoryInfo, string filename)
        {
            PropertyLister.Load();

            var datasource = await AwesomeCorpDatasource.GetSubscribers();

            using (var excel = ExcelListWriter.Write(datasource.List))
            {
                var path = Path.Combine(directoryInfo.FullName, filename);
                Logger.LogDebug("Saving excel document in " + path);
                excel.SaveAs(path);
            }
        }
Beispiel #2
0
        public void ShouldWriteHeader()
        {
            var datasoure      = new List <Subscriber> {
            };
            var excelRowWriter = Mock.Of <IExcelRowWriter <Subscriber> >();
            var headerWriter   = Mock.Of <IExcelHeaderWriter <Subscriber> >();
            var t = new ExcelListWriter <Subscriber>(headerWriter, excelRowWriter);

            var excel = t.Write(datasoure);

            Mock.Get(headerWriter).Verify(x =>
                                          x.WriteHeader(It.IsAny <IXLWorksheet>()), Times.Once);
            Assert.Pass();
        }
Beispiel #3
0
        /// <summary>
        /// Outputs list of strings with header into specified in configuration file way
        /// </summary>
        /// <param name="files">List of strings to be outputed</param>
        /// <param name="header">Header of output</param>
        /// <param name="outputFile">String of file in configuration</param>
        private void OutputList(List <string> files, string header, string outputFile = "")
        {
            IListWriter listWriter;

            //If output value in configuraton file is set to 'excel' - write to excel file
            //Otherwise - write to console.
            if (this.Configuration["output"] == "excel")
            {
                listWriter = new ExcelListWriter(this.Configuration[outputFile]);
            }
            else
            {
                listWriter = new ConsoleListWriter();
            }

            listWriter.WriteList(files, header);
        }
Beispiel #4
0
        public void ShouldWriteTwoRows()
        {
            var datasoure = new List <Subscriber> {
                new Subscriber
                {
                },
                new Subscriber
                {
                }
            };
            var excelRowWriter = Mock.Of <IExcelRowWriter <Subscriber> >();
            var headerWriter   = Mock.Of <IExcelHeaderWriter <Subscriber> >();
            var t = new ExcelListWriter <Subscriber>(headerWriter, excelRowWriter);

            var excel = t.Write(datasoure);

            Mock.Get(excelRowWriter).Verify(x =>
                                            x.WriteRow(It.IsAny <IXLWorksheet>(), It.IsAny <Subscriber>(), It.IsAny <int>()), Times.Exactly(2));

            Assert.Pass();
        }