public void GetAllOutgoingLinks() { ISettingsStorageProviderV40 prov = GetProvider(); prov.StoreOutgoingLinks("Page1", new string[] { "Page2", "Page3" }); prov.StoreOutgoingLinks("Page2", new string[] { "Page4", "Page5", "Page6" }); prov.StoreOutgoingLinks("Page3", new string[] { "Page2", "Page5" }); IDictionary <string, string[]> links = prov.GetAllOutgoingLinks(); Assert.AreEqual(3, links.Count, "Wrong source page count"); Assert.AreEqual(2, links["Page1"].Length, "Wrong link count"); Array.Sort(links["Page1"]); Assert.AreEqual("Page2", links["Page1"][0], "Wrong link"); Assert.AreEqual("Page3", links["Page1"][1], "Wrong link"); Assert.AreEqual(3, links["Page2"].Length, "Wrong link count"); Array.Sort(links["Page2"]); Assert.AreEqual("Page4", links["Page2"][0], "Wrong link"); Assert.AreEqual("Page5", links["Page2"][1], "Wrong link"); Assert.AreEqual("Page6", links["Page2"][2], "Wrong link"); Assert.AreEqual(2, links["Page3"].Length, "Wrong link count"); Array.Sort(links["Page3"]); Assert.AreEqual("Page2", links["Page3"][0], "Wrong link"); Assert.AreEqual("Page5", links["Page3"][1], "Wrong link"); }
public void GetMetaDataItem_Inexistent() { ISettingsStorageProviderV40 prov = GetProvider(); Assert.AreEqual("", prov.GetMetaDataItem(MetaDataItem.AccountActivationMessage, null), "GetMetaDataItem should return an empty string"); Assert.AreEqual("", prov.GetMetaDataItem(MetaDataItem.AccountActivationMessage, "BLAH"), "GetMetaDataItem should return an empty string"); }
public void DeleteOutgoingLinks() { ISettingsStorageProviderV40 prov = GetProvider(); prov.StoreOutgoingLinks("Page1", new string[] { "Page2", "Page3", "Page100" }); prov.StoreOutgoingLinks("Page2", new string[] { "Page4", "Page5", "Page6" }); prov.StoreOutgoingLinks("Page3", new string[] { "Page1", "Page6" }); Assert.IsFalse(prov.DeleteOutgoingLinks("Page21"), "DeleteOutgoingLinks should return false"); Assert.IsTrue(prov.DeleteOutgoingLinks("Page100"), "DeleteOutgoingLinks should return true"); Assert.IsTrue(prov.DeleteOutgoingLinks("Page1"), "DeleteOutgoingLinks should return true"); Assert.AreEqual(0, prov.GetOutgoingLinks("Page1").Length, "Links not deleted"); Assert.AreEqual(3, prov.GetOutgoingLinks("Page2").Length, "Wrong link count"); Assert.AreEqual(1, prov.GetOutgoingLinks("Page3").Length, "Wrong link count"); IDictionary <string, string[]> links = prov.GetAllOutgoingLinks(); Assert.AreEqual(2, links.Count, "Wrong source page count"); Assert.AreEqual(3, links["Page2"].Length, "Wrong link count"); Array.Sort(links["Page2"]); Assert.AreEqual("Page4", links["Page2"][0], "Wrong link"); Assert.AreEqual("Page5", links["Page2"][1], "Wrong link"); Assert.AreEqual("Page6", links["Page2"][2], "Wrong link"); Assert.AreEqual(1, links["Page3"].Length, "Wrong link count"); Assert.AreEqual("Page6", links["Page3"][0], "Wrong link"); }
public void UpdateOutgoingLinksForRename() { ISettingsStorageProviderV40 prov = GetProvider(); prov.StoreOutgoingLinks("Page1", new string[] { "Page2", "OldPage" }); prov.StoreOutgoingLinks("Page2", new string[] { "Page4", "Page5", "Page6" }); prov.StoreOutgoingLinks("OldPage", new string[] { "Page2", "Page5" }); Assert.IsFalse(prov.UpdateOutgoingLinksForRename("Inexistent", "NewName"), "UpdateOutgoingLinksForRename should return false"); Assert.IsTrue(prov.UpdateOutgoingLinksForRename("OldPage", "Page3"), "UpdateOutgoingLinksForRename should return true"); IDictionary <string, string[]> links = prov.GetAllOutgoingLinks(); Assert.AreEqual(3, links.Count, "Wrong source page count"); Assert.AreEqual(2, links["Page1"].Length, "Wrong link count"); Array.Sort(links["Page1"]); Assert.AreEqual("Page2", links["Page1"][0], "Wrong link"); Assert.AreEqual("Page3", links["Page1"][1], "Wrong link"); Assert.AreEqual(3, links["Page2"].Length, "Wrong link count"); Array.Sort(links["Page2"]); Assert.AreEqual("Page4", links["Page2"][0], "Wrong link"); Assert.AreEqual("Page5", links["Page2"][1], "Wrong link"); Assert.AreEqual("Page6", links["Page2"][2], "Wrong link"); Assert.AreEqual(2, links["Page3"].Length, "Wrong link count"); Array.Sort(links["Page3"]); Assert.AreEqual("Page2", links["Page3"][0], "Wrong link"); Assert.AreEqual("Page5", links["Page3"][1], "Wrong link"); }
public void StoreOutgoingLinks_GetOutgoingLinks_EmptyLinks() { ISettingsStorageProviderV40 prov = GetProvider(); Assert.IsTrue(prov.StoreOutgoingLinks("Page", new string[0]), "StoreOutgoingLinks should return true even if outgoingLinks is empty"); Assert.AreEqual(0, prov.GetOutgoingLinks("Page").Length, "Wrong link count"); }
public void Init() { ISettingsStorageProviderV40 prov = GetProvider(); prov.Init(MockHost(), ConfigurationManager.AppSettings["AzureConnString"], ""); Assert.IsNotNull(prov.Information, "Information should not be null"); }
public void AddRecentChange_InvalidUser(string u) { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; prov.AddRecentChange("Page", "Title", null, DateTime.Now, u, ScrewTurn.Wiki.PluginFramework.Change.PageDeleted, "Descr"); }
public void GetPluginStatus_InvalidTypeName(string tn) { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; prov.GetPluginStatus(tn); }
public void Init() { ISettingsStorageProviderV40 prov = GetProvider(); prov.Init(MockHost(), ConnString + InitialCatalog, "-"); Assert.IsNotNull(prov.Information, "Information should not be null"); }
public void GetPluginConfiguration_InvalidTypeName(string tn) { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; prov.GetPluginConfiguration(tn); }
public void SetSetting_GetSetting(string c, string r) { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; Assert.IsTrue(prov.SetSetting("TS", c), "SetSetting should return true"); Assert.AreEqual(r, prov.GetSetting("TS"), "Wrong return value"); }
public void SetMetaDataItem_GetMetaDataItem(MetaDataItem item, string newContent) { ISettingsStorageProviderV40 prov = GetProvider(); Assert.IsTrue(prov.SetMetaDataItem(item, null, newContent), "SetMetaDataItem should return true"); Assert.AreEqual(newContent, prov.GetMetaDataItem(item, null), "Wrong content"); Assert.IsTrue(prov.SetMetaDataItem(item, "Tag", newContent + "Mod"), "SetMetaDataItem should return true"); Assert.AreEqual(newContent + "Mod", prov.GetMetaDataItem(item, "Tag"), "Wrong content"); }
public void SetMetaDataItem_NullContent() { ISettingsStorageProviderV40 prov = GetProvider(); Assert.IsTrue(prov.SetMetaDataItem(MetaDataItem.Header, null, null), "SetMetaDataItem should return true"); Assert.AreEqual("", prov.GetMetaDataItem(MetaDataItem.Header, null), "Wrong content"); Assert.IsTrue(prov.SetMetaDataItem(MetaDataItem.Header, "Tag", null), "SetMetaDataItem should return true"); Assert.AreEqual("", prov.GetMetaDataItem(MetaDataItem.Header, "Tag"), "Wrong content"); }
public void AddRecentChange_CutRecentChanges() { ISettingsStorageProviderV40 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.ToString() + ")"); }
public void SetPluginStatus_RetrievePluginStatus() { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; Assert.IsTrue(prov.GetPluginStatus("My.Test.Plugin"), "GetPluginStatus should return true"); Assert.IsTrue(prov.SetPluginStatus("My.Test.Plugin", true), "SetPluginStatus should return true"); Assert.IsTrue(prov.GetPluginStatus("My.Test.Plugin"), "GetPluginStatus should return true"); Assert.IsTrue(prov.SetPluginStatus("My.Test.Plugin", false), "SetPluginStatus should return true"); Assert.IsFalse(prov.GetPluginStatus("My.Test.Plugin"), "GetPluginStatus should return false"); }
public void SetSetting_GetAllSettings() { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; Assert.IsTrue(prov.SetSetting("TS1", "Value1"), "SetSetting should return true"); Assert.IsTrue(prov.SetSetting("TS2", "Value2"), "SetSetting should return true"); Assert.IsTrue(prov.SetSetting("TS3", "Value3"), "SetSetting should return true"); IDictionary <string, string> settings = prov.GetAllSettings(); Assert.AreEqual(3, settings.Count, "Wrong setting count"); Assert.AreEqual("Value1", settings["TS1"], "Wrong setting value"); Assert.AreEqual("Value2", settings["TS2"], "Wrong setting value"); Assert.AreEqual("Value3", settings["TS3"], "Wrong setting value"); }
public void StoreOutgoingLinks_GetOutgoingLinks() { ISettingsStorageProviderV40 prov = GetProvider(); Assert.AreEqual(0, prov.GetOutgoingLinks("Page").Length, "Wrong initial link count"); Assert.IsTrue(prov.StoreOutgoingLinks("Page", new string[] { "Page2", "Sub.Page", "Page3" }), "StoreOutgoingLinks should return true"); string[] links = prov.GetOutgoingLinks("Page"); Assert.AreEqual(3, links.Length, "Wrong link count"); Array.Sort(links); Assert.AreEqual("Page2", links[0], "Wrong link"); Assert.AreEqual("Page3", links[1], "Wrong link"); Assert.AreEqual("Sub.Page", links[2], "Wrong link"); }
public void AclManager_StoreEntry_RetrieveAllEntries_DeleteEntry() { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; Assert.IsTrue(prov.AclManager.StoreEntry("Res", "Action", "U.User", Value.Grant), "StoreEntry should return true"); prov = null; prov = GetProvider(); //Collectors.SettingsProvider = prov; AclEntry[] entries = prov.AclManager.RetrieveAllEntries(); Assert.AreEqual(1, entries.Length, "Wrong entry count"); Assert.AreEqual("Res", entries[0].Resource, "Wrong resource"); Assert.AreEqual("Action", entries[0].Action, "Wrong action"); Assert.AreEqual("U.User", entries[0].Subject, "Wrong subject"); Assert.AreEqual(Value.Grant, entries[0].Value, "Wrong value"); prov = null; prov = GetProvider(); //Collectors.SettingsProvider = prov; Assert.IsTrue(prov.AclManager.RenameResource("Res", "NewName"), "RenameResource should return true"); entries = prov.AclManager.RetrieveAllEntries(); Assert.AreEqual(1, entries.Length, "Wrong entry count"); Assert.AreEqual("NewName", entries[0].Resource, "Wrong resource"); Assert.AreEqual("Action", entries[0].Action, "Wrong action"); Assert.AreEqual("U.User", entries[0].Subject, "Wrong subject"); Assert.AreEqual(Value.Grant, entries[0].Value, "Wrong value"); prov = null; prov = GetProvider(); //Collectors.SettingsProvider = prov; Assert.IsTrue(prov.AclManager.DeleteEntry("NewName", "Action", "U.User"), "DeleteEntry should return true"); prov = null; prov = GetProvider(); //Collectors.SettingsProvider = prov; Assert.AreEqual(0, prov.AclManager.RetrieveAllEntries().Length, "Wrong entry count"); }
public void PlainTest(string input, string output) { mocks = new MockRepository(); ISettingsStorageProviderV40 settingsProvider = mocks.StrictMock <ISettingsStorageProviderV40>(); ICollectorsBox collectorsBox = mocks.DynamicMock <ICollectorsBox>(); Collectors.CollectorsBox = collectorsBox; using (mocks.Record()) { Expect.Call(settingsProvider.GetSetting("ProcessSingleLineBreaks")).Return("true").Repeat.Any(); Expect.Call(collectorsBox.GetSettingsProvider(null)).Return(settingsProvider).Repeat.Any(); } using (mocks.Playback()) { ReverseFormatter reverseFormatter = new ReverseFormatter(); Assert.AreEqual(output, reverseFormatter.ReverseFormat(null, input)); } }
public void AddRecentChange_NullMessageSubject_NullDescription() { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; DateTime dt = DateTime.UtcNow; 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 SetPluginConfiguration_GetPluginConfiguration() { ISettingsStorageProviderV40 prov = GetProvider(); //Collectors.SettingsProvider = prov; Assert.IsEmpty(prov.GetPluginConfiguration("My.Test.Plugin"), "GetPluginConfiguration should return an empty string"); Assert.IsTrue(prov.SetPluginConfiguration("My.Test.Plugin", "config"), "SetPluginConfiguration should return true"); Assert.AreEqual("config", prov.GetPluginConfiguration("My.Test.Plugin"), "Wrong config"); Assert.IsTrue(prov.SetPluginConfiguration("My.Test.Plugin", "config222"), "SetPluginConfiguration should return true"); Assert.AreEqual("config222", prov.GetPluginConfiguration("My.Test.Plugin"), "Wrong config"); Assert.IsTrue(prov.SetPluginConfiguration("My.Test.Plugin", ""), "SetPluginConfiguration should return true"); Assert.AreEqual("", prov.GetPluginConfiguration("My.Test.Plugin"), "Wrong config"); Assert.IsTrue(prov.SetPluginConfiguration("My.Test.Plugin", null), "SetPluginConfiguration should return true"); Assert.AreEqual("", prov.GetPluginConfiguration("My.Test.Plugin"), "Wrong config"); }
public void UpdateOutgoingLinksForRename_InvalidNewName(string n) { ISettingsStorageProviderV40 prov = GetProvider(); prov.UpdateOutgoingLinksForRename("OldName", n); }
public void Init_NullHost() { ISettingsStorageProviderV40 prov = GetProvider(); prov.Init(null, "", ""); }
public void DeleteOutgoingLinks_InvalidPage(string p) { ISettingsStorageProviderV40 prov = GetProvider(); prov.DeleteOutgoingLinks(p); }
public void Init_NullConfig() { ISettingsStorageProviderV40 prov = GetProvider(); prov.Init(MockHost(), null, ""); }
public void StoreOutgoingLinks_InvalidPage(string p) { ISettingsStorageProviderV40 prov = GetProvider(); prov.StoreOutgoingLinks(p, new string[] { "P1", "P2" }); }
public void GetSetting_InvalidName(string n) { ISettingsStorageProviderV40 prov = GetProvider(); prov.GetSetting(n); }
public void StoreOutgoingLinks_NullLinks() { ISettingsStorageProviderV40 prov = GetProvider(); prov.StoreOutgoingLinks("Page", null); }
/// <summary> /// Initializes a new instance of the <see cref="AuthReader"/> class. /// </summary> /// <param name="settingsProvider">The settings provider.</param> public AuthReader(ISettingsStorageProviderV40 settingsProvider) { _settingsProvider = settingsProvider; }
public void StoreOutgoingLinks_InvalidLinksEntry(string e) { ISettingsStorageProviderV40 prov = GetProvider(); prov.StoreOutgoingLinks("Page", new string[] { "P1", e, "P3" }); }