Esempio n. 1
0
        public void AndRequiredAttributesEmpty_ThenElementListedAsInvalid()
        {
            var xmlParser  = new RecorderScheduleXmlParser(string.Format("{0}\\validXml_EmptyAttribute.xml", this.assemblyDirectory));
            var recordings = xmlParser.ExtractRecordings();

            Assert.IsTrue(recordings.All(x => !string.IsNullOrEmpty(x.Title)));
        }
Esempio n. 2
0
        public void AndHasAllRequiredAttributes_ThenRecordingObjectCreated()
        {
            var xmlParser  = new RecorderScheduleXmlParser(string.Format("{0}\\validXml.xml", this.assemblyDirectory));
            var recordings = xmlParser.ExtractRecordings();

            Assert.IsTrue(recordings.All(x => !string.IsNullOrEmpty(x.Title)));
        }
Esempio n. 3
0
        private DataView PreviewTable(string fileName)
        {
            DataTable table      = new DataTable();
            int       lineNumber = 0;

            try
            {
                table.Columns.Add(NUMBER);
                table.Columns.Add(TITLE);
                table.Columns.Add(RECORDING_DATE);
                table.Columns.Add(START_TIME);
                table.Columns.Add(END_TIME);
                table.Columns.Add(PRESENTER);
                table.Columns.Add(FOLDER);
                table.Columns.Add(ISWEBCAST);

                IEnumerable <Recording> recordings = null;
                if (System.IO.Path.GetExtension(fileName) == ".xml")
                {
                    var parser = new RecorderScheduleXmlParser(fileName);
                    recordings = parser.ExtractRecordings();
                }
                else if (System.IO.Path.GetExtension(fileName) == ".csv")
                {
                    var parser = new RecorderScheduleCSVParser(fileName);
                    recordings = parser.ExtractRecordings();
                }
                lineNumber++;

                int rowCount = 0;
                foreach (var recording in recordings)
                {
                    var row = table.NewRow();
                    rowCount++; row[NUMBER] = rowCount;
                    row[TITLE]          = recording.Title;
                    row[START_TIME]     = recording.StartTime.ToShortTimeString();
                    row[END_TIME]       = recording.EndTime.ToShortTimeString();
                    row[PRESENTER]      = recording.Presenter;
                    row[FOLDER]         = recording.CourseTitle;
                    row[RECORDING_DATE] = recording.RecordingDate;
                    row[ISWEBCAST]      = recording.IsBroadCast.ToString();
                    table.Rows.Add(row);
                }
            }
            catch (Exception ex)
            {
                log.Warn(ex);
                MessageBox.Show(ex.Message);
            }

            return(table.AsDataView());
        }