public void TestReconstructionFromCsv() { var opts = new IsIdentifiableRelationalDatabaseOptions(); var dir = new DirectoryInfo(TestContext.CurrentContext.WorkDirectory); foreach (var f in dir.GetFiles("*HappyOzz*.csv")) { f.Delete(); } opts.DestinationCsvFolder = dir.FullName; opts.TableName = "HappyOzz"; opts.StoreReport = true; FailureStoreReport report = new FailureStoreReport("HappyOzz", 1000); report.AddDestinations(opts); var failure = new Failure( new FailurePart[] { new FailurePart("Kansas", FailureClassification.Location, 12), new FailurePart("Toto", FailureClassification.Location, 28) }) { ProblemValue = "We aren't in Kansas anymore Toto", ProblemField = "Narrative", ResourcePrimaryKey = "1.2.3", Resource = "FunBooks.HappyOzz" }; report.Add(failure); report.CloseReport(); var created = dir.GetFiles("*HappyOzz*.csv").SingleOrDefault(); Assert.IsNotNull(created); var report2 = new FailureStoreReport("", 0); var failures2 = report2.Deserialize(created).ToArray(); //read failure ok Assert.AreEqual(1, failures2.Length); Assert.AreEqual(failure.ProblemValue, failures2[0].ProblemValue); Assert.AreEqual(failure.ProblemField, failures2[0].ProblemField); Assert.AreEqual(failure.ResourcePrimaryKey, failures2[0].ResourcePrimaryKey); Assert.AreEqual(failure.Resource, failures2[0].Resource); //read parts ok Assert.AreEqual(2, failures2[0].Parts.Count); Assert.AreEqual(failure.Parts[0].Classification, failures2[0].Parts[0].Classification); Assert.AreEqual(failure.Parts[0].Offset, failures2[0].Parts[0].Offset); Assert.AreEqual(failure.Parts[0].Word, failures2[0].Parts[0].Word); Assert.AreEqual(failure.Parts[1].Classification, failures2[0].Parts[1].Classification); Assert.AreEqual(failure.Parts[1].Offset, failures2[0].Parts[1].Offset); Assert.AreEqual(failure.Parts[1].Word, failures2[0].Parts[1].Word); }
public ReportReader(FileInfo csvFile, Action <int> loadedRows, CancellationToken token) { var report = new FailureStoreReport("", 0); Failures = report.Deserialize(csvFile, loadedRows, token).ToArray(); }
public ReportReader(FileInfo csvFile) { var report = new FailureStoreReport("", 0); Failures = report.Deserialize(csvFile).ToArray(); }