public void Constructor_WorkingLiftFolderDoesntExist_Throws() { using (TempFolder cache = new TempFolder("LiftChangeDetectorTestsCache")) { LiftChangeDetector detector = new LiftChangeDetector("notgonnafindme", cache.Path); detector.Reset(); } }
public void CanProvideChangeRecord_AfterReset_True() { using (TempFile working = new TempFile("<lift version='0.12'/>")) { using (TempFolder cache = new TempFolder("LiftChangeDetectorTestsCache")) { LiftChangeDetector detector = new LiftChangeDetector(working.Path, cache.Path); detector.Reset(); Assert.IsTrue(detector.CanProvideChangeRecord); } } }
public void GetChangeReport_AfterChange_Reasonable() { using (TempFile working = new TempFile(_originalLift)) { using (TempFolder cache = new TempFolder("LiftChangeDetectorTestsCache")) { LiftChangeDetector detector = new LiftChangeDetector(working.Path, cache.Path); detector.Reset(); File.WriteAllText(working.Path, _modifiedLift); ILiftChangeReport report = detector.GetChangeReport(new NullProgress()); Assert.AreEqual(LiftChangeReport.ChangeType.Editted, report.GetChangeType("one")); Assert.AreEqual(LiftChangeReport.ChangeType.Deleted, report.GetChangeType("two")); Assert.AreEqual(1, report.IdsOfDeletedEntries.Count); } } }
public void GetChangeReport_NoChanges_PerformanceTest() { using (TempFile working = new TempFile(_originalLift)) { int howManyEntries = 10000; Debug.WriteLine("running test using "+howManyEntries.ToString()+" entries"); using (XmlWriter w = XmlWriter.Create(working.Path)) { w.WriteStartElement("lift"); for (int i = 0; i < howManyEntries; i++) { w.WriteStartElement("entry"); w.WriteAttributeString("id", i.ToString()); w.WriteElementString("lexical-unit", "<form lang='x'><text>" + Path.GetRandomFileName() //just a way to get some random text + "</text></form>"); w.WriteElementString("gloss", "<form lang='y'><text>" + Path.GetRandomFileName() //just a way to get some random text + "</text></form>"); w.WriteEndElement(); } w.WriteEndElement(); } using (TempFolder cache = new TempFolder("LiftChangeDetectorTestsCache")) { LiftChangeDetector detector = new LiftChangeDetector(working.Path, cache.Path); System.Diagnostics.Stopwatch timer = new Stopwatch(); timer.Start(); detector.Reset(); timer.Stop(); Debug.WriteLine("reset took "+timer.Elapsed.TotalSeconds+" seconds"); timer.Reset(); timer.Start(); ILiftChangeReport report = detector.GetChangeReport(null); timer.Stop(); Debug.WriteLine("getting report took " + timer.Elapsed.TotalSeconds + " seconds"); timer.Reset(); timer.Start(); for (int i = 0; i < howManyEntries; i++) { report.GetChangeType(i.ToString()); } timer.Stop(); Debug.WriteLine("Time to inquire about each entry " + timer.Elapsed.TotalSeconds + " seconds"); } } }