public void Separator_Set_ValueIsSet() { var descriptor = new SeparatorSeriesDescriptor(); descriptor.Separator = ";"; Assert.That(descriptor.Separator, Is.EqualTo(";")); }
private static IFigureDescriptor CreateSeparatorSeriesDescriptor() { var desciptor = new SeparatorSeriesDescriptor(); desciptor.ValueFormat = new FormatColumn("value", typeof(double), "000,000.0000"); desciptor.TimeFormat = new FormatColumn("time", typeof(int), "0000"); return(desciptor); }
public void Separator_Set_ChangeIsNotified() { var descriptor = new SeparatorSeriesDescriptor(); var counter = new PropertyChangedCounter(descriptor); descriptor.Separator = ";"; Assert.That(counter.GetCount(nameof(descriptor.Separator)), Is.EqualTo(1)); }
public void Clone_WhenCalled_AllMembersAreCloned() { var descriptor = new SeparatorSeriesDescriptor(); descriptor.Separator = "#"; var clone = FigureDescriptorFactory.Clone(descriptor); Assert.That(clone.Separator, Is.EqualTo("#")); }
public void Validate_MissingValueLocator_Throws() { var descriptor = new SeparatorSeriesDescriptor(); descriptor.ValuesLocator = null; descriptor.ValueFormat = new FormatColumn("values", typeof(double), "0.00"); var ex = Assert.Throws <ValidationException>(() => RecursiveValidator.Validate(descriptor)); Assert.That(ex.Message, Does.Contain("The ValuesLocator field is required")); }
public void Validate_MissingValueFormat_Throws() { var descriptor = new SeparatorSeriesDescriptor(); descriptor.ValuesLocator = new AbsolutePositionLocator { HeaderSeriesPosition = 0, SeriesPosition = 4 }; descriptor.ValueFormat = null; var ex = Assert.Throws <ValidationException>(() => RecursiveValidator.Validate(descriptor)); Assert.That(ex.Message, Does.Contain("The ValueFormat field is required")); }
public void Validate_IsValid_DoesNotThrows() { var descriptor = new SeparatorSeriesDescriptor(); descriptor.Figure = "Dept"; descriptor.Separator = "#"; descriptor.ValuesLocator = new AbsolutePositionLocator { HeaderSeriesPosition = 0, SeriesPosition = 4 }; descriptor.ValueFormat = new FormatColumn("values", typeof(double), "0.00"); RecursiveValidator.Validate(descriptor); }
public void Validate_InvalidSeparator_Throws([Values(null, "")] string seperator) { var descriptor = new SeparatorSeriesDescriptor(); descriptor.Figure = "Dept"; descriptor.Separator = seperator; descriptor.ValuesLocator = new AbsolutePositionLocator { HeaderSeriesPosition = 0, SeriesPosition = 4 }; descriptor.ValueFormat = new FormatColumn("values", typeof(double), "0.00"); var ex = Assert.Throws <ValidationException>(() => RecursiveValidator.Validate(descriptor)); Assert.That(ex.Message, Does.Contain("The Separator field is required")); }
public void GetSeries() { var descriptor = new SeparatorSeriesDescriptor(); descriptor.Figure = "EarningsPerShare"; descriptor.Separator = ";"; descriptor.Orientation = SeriesOrientation.Row; descriptor.ValuesLocator = new StringContainsLocator { HeaderSeriesPosition = 0, Pattern = "EPS" }; descriptor.TimesLocator = new AbsolutePositionLocator { HeaderSeriesPosition = 0, SeriesPosition = 0 }; descriptor.Excludes.AddRange(0, 1); descriptor.ValueFormat = new FormatColumn("value", typeof(double), "000,00"); descriptor.TimeFormat = new FormatColumn("year", typeof(int), "000"); var doc = LoadDocument <TextDocument>("Csv", "DE0005151005.csv"); var parser = DocumentProcessingFactory.CreateParser(doc, descriptor); var table = parser.ExtractTable(); Assert.AreEqual(10, table.Rows.Count); Assert.AreEqual(3.2d, ( double )table.Rows[0]["value"], 0.000001d); Assert.AreEqual(3.4d, ( double )table.Rows[1]["value"], 0.000001d); Assert.AreEqual(3.4d, ( double )table.Rows[2]["value"], 0.000001d); Assert.AreEqual(3.3d, ( double )table.Rows[3]["value"], 0.000001d); Assert.AreEqual(2.9d, ( double )table.Rows[4]["value"], 0.000001d); Assert.AreEqual(2.8d, ( double )table.Rows[5]["value"], 0.000001d); Assert.AreEqual(3.0d, ( double )table.Rows[6]["value"], 0.000001d); Assert.AreEqual(3.0d, ( double )table.Rows[7]["value"], 0.000001d); Assert.AreEqual(3.1d, ( double )table.Rows[8]["value"], 0.000001d); Assert.AreEqual(3.5d, ( double )table.Rows[9]["value"], 0.000001d); Assert.AreEqual(1997, ( int )table.Rows[0]["year"]); Assert.AreEqual(1998, ( int )table.Rows[1]["year"]); Assert.AreEqual(1999, ( int )table.Rows[2]["year"]); Assert.AreEqual(2000, ( int )table.Rows[3]["year"]); Assert.AreEqual(2001, ( int )table.Rows[4]["year"]); Assert.AreEqual(2002, ( int )table.Rows[5]["year"]); Assert.AreEqual(2003, ( int )table.Rows[6]["year"]); Assert.AreEqual(2004, ( int )table.Rows[7]["year"]); Assert.AreEqual(2005, ( int )table.Rows[8]["year"]); Assert.AreEqual(2006, ( int )table.Rows[9]["year"]); }
public DataTable ExtractTable() { SeparatorSeriesDescriptor separatorSeriesDescriptor = myDescriptor as SeparatorSeriesDescriptor; CsvDescriptor csvDescriptor = myDescriptor as CsvDescriptor; if (csvDescriptor != null) { DataTable result = CsvReader.Read(myDocument.Location.LocalPath, csvDescriptor.Separator); return(TableFormatter.ToFormattedTable(csvDescriptor, result)); } else if (separatorSeriesDescriptor != null) { DataTable result = CsvReader.Read(myDocument.Location.LocalPath, separatorSeriesDescriptor.Separator); return(TableFormatter.ToFormattedTable(separatorSeriesDescriptor, result)); } else { throw new NotSupportedException("Format not supported for text files: " + myDescriptor.GetType()); } }