Ejemplo n.º 1
0
        public void TestFormatTitle()
        {
            var formatter = new CsvFormatter();
            var buffer    = new StringBuilder();

            buffer.Append(formatter.FormatTitle(typeof(Model)));
            Assert.AreEqual("Field1,Property1", buffer.ToString());
        }
        private static string GenerateCSV(Device[] data)
        {
            var formatter = new CsvFormatter();
            var buffer    = new StringBuilder();

            buffer.Append(formatter.FormatTitle(typeof(Device)));
            buffer.Append("\n");
            foreach (Device item in data)
            {
                try
                {
                    buffer.Append(formatter.FormatItem(item) + '\n');
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Buffer Append Failed: {item} ({e.InnerException})");
                }
            }
            return(buffer.ToString());
        }