public void AddRecentChange_InvalidUser(string u) { ISettingsStorageProviderV30 prov = GetProvider(); Collectors.SettingsProvider = prov; prov.AddRecentChange("Page", "Title", null, DateTime.Now, u, ScrewTurn.Wiki.PluginFramework.Change.PageDeleted, "Descr"); }
public void AddRecentChange_InvalidUser_ShouldThrowArgumentException(string u) { Assert.Throws <ArgumentException>(() => { ISettingsStorageProviderV30 prov = GetProvider(); Collectors.SettingsProvider = prov; prov.AddRecentChange("Page", "Title", null, DateTime.Now, u, ScrewTurn.Wiki.PluginFramework.Change.PageDeleted, "Descr"); }); }
public void AddRecentChange_CutRecentChanges() { ISettingsStorageProviderV30 prov = GetProvider(); Collectors.SettingsProvider = prov; for (int i = 0; i < MaxRecentChanges + 8; i++) { Assert.IsTrue(prov.AddRecentChange("MainPage", "Main Page", null, DateTime.Now, Log.SystemUsername, ScrewTurn.Wiki.PluginFramework.Change.PageUpdated, ""), "AddRecentChange should return true"); } RecentChange[] changes = prov.GetRecentChanges(); Assert.IsTrue(changes.Length > 0 && changes.Length <= MaxRecentChanges, "Wrong recent change count (" + changes.Length + ")"); }
public void AddRecentChange_NullMessageSubject_NullDescription() { ISettingsStorageProviderV30 prov = GetProvider(); Collectors.SettingsProvider = prov; DateTime dt = DateTime.Now; Assert.IsTrue(prov.AddRecentChange("Page", "Title", null, dt, "User", ScrewTurn.Wiki.PluginFramework.Change.PageUpdated, null), "AddRecentChange should return true"); RecentChange c = prov.GetRecentChanges()[0]; Assert.AreEqual("Page", c.Page, "Wrong page"); Assert.AreEqual("Title", c.Title, "Wrong title"); Assert.AreEqual("", c.MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt, c.DateTime); Assert.AreEqual("User", c.User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.PageUpdated, c.Change, "Wrong change"); Assert.AreEqual("", c.Description, "Wrong description"); }
public void AddRecentChange_GetRecentChanges() { ISettingsStorageProviderV30 prov = GetProvider(); Collectors.SettingsProvider = prov; DateTime dt = DateTime.Now; Assert.IsTrue(prov.AddRecentChange("MainPage", "Main Page", null, dt, Log.SystemUsername, ScrewTurn.Wiki.PluginFramework.Change.PageUpdated, ""), "AddRecentChange should return true"); Assert.IsTrue(prov.AddRecentChange("MainPage", "Home Page", null, dt.AddHours(1), "admin", ScrewTurn.Wiki.PluginFramework.Change.PageUpdated, "Added info"), "AddRecentChange should return true"); Assert.IsTrue(prov.AddRecentChange("MainPage", "Home Page", null, dt.AddHours(5), "admin", ScrewTurn.Wiki.PluginFramework.Change.PageRenamed, ""), "AddRecentChange should return true"); Assert.IsTrue(prov.AddRecentChange("MainPage", "Main Page", null, dt.AddHours(6), "admin", ScrewTurn.Wiki.PluginFramework.Change.PageRolledBack, ""), "AddRecentChange should return true"); Assert.IsTrue(prov.AddRecentChange("MainPage", "Main Page", null, dt.AddHours(7), "admin", ScrewTurn.Wiki.PluginFramework.Change.PageDeleted, ""), "AddRecentChange should return true"); Assert.IsTrue(prov.AddRecentChange("MainPage", "Main Page", "Subject", dt.AddHours(2), "admin", ScrewTurn.Wiki.PluginFramework.Change.MessagePosted, ""), "AddRecentChange should return true"); Assert.IsTrue(prov.AddRecentChange("MainPage", "Main Page", "Subject", dt.AddHours(3), "admin", ScrewTurn.Wiki.PluginFramework.Change.MessageEdited, ""), "AddRecentChange should return true"); Assert.IsTrue(prov.AddRecentChange("MainPage", "Main Page", "Subject", dt.AddHours(4), "admin", ScrewTurn.Wiki.PluginFramework.Change.MessageDeleted, ""), "AddRecentChange should return true"); RecentChange[] changes = prov.GetRecentChanges(); Assert.AreEqual(8, changes.Length, "Wrong recent change count"); Assert.AreEqual("MainPage", changes[0].Page, "Wrong page"); Assert.AreEqual("Main Page", changes[0].Title, "Wrong title"); Assert.AreEqual("", changes[0].MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt, changes[0].DateTime); Assert.AreEqual(Log.SystemUsername, changes[0].User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.PageUpdated, changes[0].Change, "Wrong change"); Assert.AreEqual("", changes[0].Description, "Wrong description"); Assert.AreEqual("MainPage", changes[1].Page, "Wrong page"); Assert.AreEqual("Home Page", changes[1].Title, "Wrong title"); Assert.AreEqual("", changes[1].MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt.AddHours(1), changes[1].DateTime); Assert.AreEqual("admin", changes[1].User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.PageUpdated, changes[1].Change, "Wrong change"); Assert.AreEqual("Added info", changes[1].Description, "Wrong description"); Assert.AreEqual("MainPage", changes[2].Page, "Wrong page"); Assert.AreEqual("Main Page", changes[2].Title, "Wrong title"); Assert.AreEqual("Subject", changes[2].MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt.AddHours(2), changes[2].DateTime); Assert.AreEqual("admin", changes[2].User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.MessagePosted, changes[2].Change, "Wrong change"); Assert.AreEqual("", changes[2].Description, "Wrong description"); Assert.AreEqual("MainPage", changes[3].Page, "Wrong page"); Assert.AreEqual("Main Page", changes[3].Title, "Wrong title"); Assert.AreEqual("Subject", changes[3].MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt.AddHours(3), changes[3].DateTime); Assert.AreEqual("admin", changes[3].User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.MessageEdited, changes[3].Change, "Wrong change"); Assert.AreEqual("", changes[3].Description, "Wrong description"); Assert.AreEqual("MainPage", changes[4].Page, "Wrong page"); Assert.AreEqual("Main Page", changes[4].Title, "Wrong title"); Assert.AreEqual("Subject", changes[4].MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt.AddHours(4), changes[4].DateTime); Assert.AreEqual("admin", changes[4].User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.MessageDeleted, changes[4].Change, "Wrong change"); Assert.AreEqual("", changes[4].Description, "Wrong description"); Assert.AreEqual("MainPage", changes[5].Page, "Wrong page"); Assert.AreEqual("Home Page", changes[5].Title, "Wrong title"); Assert.AreEqual("", changes[5].MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt.AddHours(5), changes[5].DateTime); Assert.AreEqual("admin", changes[5].User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.PageRenamed, changes[5].Change, "Wrong change"); Assert.AreEqual("", changes[5].Description, "Wrong description"); Assert.AreEqual("MainPage", changes[6].Page, "Wrong page"); Assert.AreEqual("Main Page", changes[6].Title, "Wrong title"); Assert.AreEqual("", changes[6].MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt.AddHours(6), changes[6].DateTime); Assert.AreEqual("admin", changes[6].User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.PageRolledBack, changes[6].Change, "Wrong change"); Assert.AreEqual("", changes[6].Description, "Wrong description"); Assert.AreEqual("MainPage", changes[7].Page, "Wrong page"); Assert.AreEqual("Main Page", changes[7].Title, "Wrong title"); Assert.AreEqual("", changes[7].MessageSubject, "Wrong message subject"); Tools.AssertDateTimesAreEqual(dt.AddHours(7), changes[7].DateTime); Assert.AreEqual("admin", changes[7].User, "Wrong user"); Assert.AreEqual(ScrewTurn.Wiki.PluginFramework.Change.PageDeleted, changes[7].Change, "Wrong change"); Assert.AreEqual("", changes[7].Description, "Wrong description"); }