public void NewEntry_ByEntry_TriggersModifiedEntryAdded() { using (var f = new TemporaryFolder("eventTests")) { using (var r = new LiftLexEntryRepository(f.GetPathForNewTempFile(true))) { r.AfterEntryModified += OnEvent; LexEntry entry = r.CreateItem(); r.SaveItem(entry); Assert.IsTrue(_gotEventCall); } } }
public void DeleteEntry_ByEntry_TriggersAfterEntryDeleted() { using (TemporaryFolder f = new TemporaryFolder("eventTests")) { using (LiftLexEntryRepository r = new LiftLexEntryRepository(f.GetPathForNewTempFile(true))) { r.AfterEntryDeleted += OnEvent; LexEntry entry = r.CreateItem(); r.SaveItem(entry); r.DeleteItem(entry); Assert.IsTrue(_gotEventCall); } } }
public TempLiftFile(TemporaryFolder parentFolder, string xmlOfEntries, string claimedLiftVersion) : base(true) // True means "I'll set the the pathname, thank you very much." Otherwise, the temp one 'false' creates will stay forever, and fill the hard drive up. { if (parentFolder != null) { Path = parentFolder.GetPathForNewTempFile(false) + ".lift"; } else { Path = System.IO.Path.Combine(System.IO.Path.GetTempPath(), System.IO.Path.GetRandomFileName() + ".lift"); } string liftContents = string.Format("<?xml version='1.0' encoding='utf-8'?><lift version='{0}'>{1}</lift>", claimedLiftVersion, xmlOfEntries); RobustFile.WriteAllText(Path, liftContents); }
public TempLiftFile(TemporaryFolder parentFolder, string xmlOfEntries, string claimedLiftVersion) : base(true) // True means "I'll set the the pathname, thank you very much." Otherwise, the temp one 'false' creates will stay forever, and fill the hard drive up. { if (parentFolder != null) { _path = parentFolder.GetPathForNewTempFile(false) + ".lift"; } else { var temp = System.IO.Path.GetTempFileName(); _path = temp + ".lift"; File.Move(temp, _path); } string liftContents = string.Format("<?xml version='1.0' encoding='utf-8'?><lift version='{0}'>{1}</lift>", claimedLiftVersion, xmlOfEntries); File.WriteAllText(_path, liftContents); }
/// <summary> /// Create a tempfile within the given parent folder /// </summary> public TempFileFromFolder(TemporaryFolder parentFolder) : base(true) // True means "I'll set the the pathname, thank you very much." Otherwise, the temp one 'false' creates will stay forever, and fill the hard drive up. { Path = parentFolder != null?parentFolder.GetPathForNewTempFile(true) : System.IO.Path.GetTempFileName(); }
/// <summary> /// Create a tempfile within the given parent folder /// </summary> public TempFileFromFolder(TemporaryFolder parentFolder) : base(true) // True means "I'll set the the pathname, thank you very much." Otherwise, the temp one 'false' creates will stay forever, and fill the hard drive up. { _path = parentFolder != null ? parentFolder.GetPathForNewTempFile(true) : System.IO.Path.GetTempFileName(); }