Exemplo n.º 1
0
        public void ExportCsv_CanExportCsvHeadersOnly()
        {
            ServiceAppListExporter exporter = new ServiceAppListExporter();
            string result = exporter.ExportCsv(new List <ServiceApp>());

            // a weird test considering that the properties order can change but still be perfectly valid.
            Assert.IsTrue(result.Contains("Name,"));
        }
Exemplo n.º 2
0
        public void ExportCsv_CanExportCsvWithDetails()
        {
            var list = new List <ServiceApp>
            {
                new ServiceApp
                {
                    Name        = "Number1",
                    Description = "This \"Description\", complex",
                    AppFilePath = "C:\\Path\\File.exe"
                }
            };

            ServiceAppListExporter exporter = new ServiceAppListExporter();
            string result = exporter.ExportCsv(list);

            string[] lines = Regex.Split(result, "\r\n|\r|\n");

            Assert.IsTrue(lines.Length == 3, "Number of lines");
            Assert.IsTrue(result.Contains("Number1"), "The name");
            Assert.IsTrue(result.Contains("\"This \"\"Description\"\", complex\""), "The quotes and commas");
        }
Exemplo n.º 3
0
        /// <summary>
        /// Exports the service application list.
        /// </summary>
        /// <param name="extension">The extension.</param>
        /// <returns>
        /// The exported list
        /// </returns>
        /// <exception cref="System.NotSupportedException">Thrown when the supplied extension has not export method defined.</exception>
        public string ExportServiceAppList(string extension)
        {
            IServiceAppClient  client         = this.factory.Create <IServiceAppClient>();
            IList <ServiceApp> serviceAppList = client.GetInstalledServiceApps();

            string exportContents;
            ServiceAppListExporter listExporter = new ServiceAppListExporter();

            if (extension.Contains("txt"))
            {
                exportContents = listExporter.ExportTabDelimited(serviceAppList);
            }
            else if (extension.Contains("csv"))
            {
                exportContents = listExporter.ExportCsv(serviceAppList);
            }
            else
            {
                throw new NotSupportedException(string.Format("The {0} extension is not supported."));
            }

            return(exportContents);
        }