public void TimeSeriesGroup_AddNullElements_Throws()
        {
            var group = new TimeSeriesGroup();

            Assert.Throws <ArgumentNullException>(() => group.Add(null));
            Assert.Throws <ArgumentNullException>(() => group.AddRange(null));
            Assert.Throws <ArgumentException>(() => group.AddRange(new List <ITimeSeries>()
            {
                null
            }));
        }
Beispiel #2
0
        public void Write(IEnumerable<ITimeSeries> timeSeriesGroup, string summaryFile, SummaryConfig excelConfig)
        {
            if (timeSeriesGroup == null) throw new ArgumentNullException(nameof(timeSeriesGroup));
            if (timeSeriesGroup.Any(x => x == null)) throw new ArgumentException("IEnumerable contains null values.", nameof(timeSeriesGroup));

            if (excelConfig.Sheet == null) throw new ArgumentNullException(nameof(excelConfig.Sheet));
            if (excelConfig.Row <= 0) throw new ArgumentOutOfRangeException(nameof(excelConfig.Row), "Value must be higher than 0.");

            if (!(timeSeriesGroup is TimeSeriesGroup timeSeriesGroupInstance))
            {
                timeSeriesGroupInstance = new TimeSeriesGroup();
                timeSeriesGroupInstance.AddRange(timeSeriesGroup);
            }

            using (var excelPack = new ExcelPackage(new FileInfo(summaryFile)))
            {
                var worksheet = excelPack.Workbook.Worksheets[excelConfig.Sheet];
                if (worksheet == null)
                {
                    throw new InvalidDataException($"Table '{excelConfig.Sheet}' not found.");
                }

                var edrWorksheet = new EppWorksheet(worksheet);
                FillDataIntoTable(edrWorksheet, timeSeriesGroupInstance, excelConfig.Row);

                excelPack.Save();
            }
        }