public void CopySettingsStorageProviderData() { var mocks = new MockRepository(); var source = mocks.StrictMock <ISettingsStorageProviderV30>(); var destination = mocks.StrictMock <ISettingsStorageProviderV30>(); var sourceAclManager = mocks.StrictMock <IAclManager>(); var destinationAclManager = mocks.StrictMock <IAclManager>(); // Setup SOURCE --------------------- // Settings var settings = new Dictionary <string, string> { { "Set1", "Value1" }, { "Set2", "Value2" } }; Expect.Call(source.GetAllSettings()).Return(settings); // Meta-data (global) Expect.Call(source.GetMetaDataItem(MetaDataItem.AccountActivationMessage, null)).Return("AAM"); Expect.Call(source.GetMetaDataItem(MetaDataItem.PasswordResetProcedureMessage, null)).Return("PRM"); Expect.Call(source.GetMetaDataItem(MetaDataItem.LoginNotice, null)).Return(""); Expect.Call(source.GetMetaDataItem(MetaDataItem.PageChangeMessage, null)).Return("PCM"); Expect.Call(source.GetMetaDataItem(MetaDataItem.DiscussionChangeMessage, null)).Return("DCM"); // Meta-data (root) Expect.Call(source.GetMetaDataItem(MetaDataItem.EditNotice, null)).Return(""); Expect.Call(source.GetMetaDataItem(MetaDataItem.Footer, null)).Return("FOOT"); Expect.Call(source.GetMetaDataItem(MetaDataItem.Header, null)).Return("HEADER"); Expect.Call(source.GetMetaDataItem(MetaDataItem.HtmlHead, null)).Return("HTML"); Expect.Call(source.GetMetaDataItem(MetaDataItem.PageFooter, null)).Return("P_FOOT"); Expect.Call(source.GetMetaDataItem(MetaDataItem.PageHeader, null)).Return("P_HEADER"); Expect.Call(source.GetMetaDataItem(MetaDataItem.Sidebar, null)).Return("SIDEBAR"); // Meta-data ("NS" namespace) Expect.Call(source.GetMetaDataItem(MetaDataItem.EditNotice, "NS")).Return("NS_EDIT"); Expect.Call(source.GetMetaDataItem(MetaDataItem.Footer, "NS")).Return("NS_FOOT"); Expect.Call(source.GetMetaDataItem(MetaDataItem.Header, "NS")).Return("NS_HEADER"); Expect.Call(source.GetMetaDataItem(MetaDataItem.HtmlHead, "NS")).Return("NS_HTML"); Expect.Call(source.GetMetaDataItem(MetaDataItem.PageFooter, "NS")).Return("NS_P_FOOT"); Expect.Call(source.GetMetaDataItem(MetaDataItem.PageHeader, "NS")).Return("NS_P_HEADER"); Expect.Call(source.GetMetaDataItem(MetaDataItem.Sidebar, "NS")).Return("NS_SIDEBAR"); // Plugin assemblies byte[] asm1 = { 1, 2, 3, 4, 5 }; byte[] asm2 = { 6, 7, 8, 9, 10, 11, 12 }; Expect.Call(source.ListPluginAssemblies()).Return(new[] { "Plugins1.dll", "Plugins2.dll" }); Expect.Call(source.RetrievePluginAssembly("Plugins1.dll")).Return(asm1); Expect.Call(source.RetrievePluginAssembly("Plugins2.dll")).Return(asm2); // Plugin status Expect.Call(source.GetPluginStatus("Test1.Plugin1")).Return(true); Expect.Call(source.GetPluginStatus("Test2.Plugin2")).Return(false); // Plugin config Expect.Call(source.GetPluginConfiguration("Test1.Plugin1")).Return("Config1"); Expect.Call(source.GetPluginConfiguration("Test2.Plugin2")).Return(""); // Outgoing links var outgoingLinks = new Dictionary <string, string[]> { { "Page1", new[] { "Page2", "Page3" } }, { "Page2", new[] { "Page3" } }, { "Page3", new[] { "Page4", "Page3" } } }; Expect.Call(source.GetAllOutgoingLinks()).Return(outgoingLinks); // ACLs Expect.Call(source.AclManager).Return(sourceAclManager); AclEntry[] entries = { new AclEntry("Res1", "Act1", "Subj1", Value.Grant), new AclEntry("Res2", "Act2", "Subj2", Value.Deny) }; Expect.Call(sourceAclManager.RetrieveAllEntries()).Return(entries); // Setup DESTINATION ----------------- // Settings destination.BeginBulkUpdate(); LastCall.On(destination).Repeat.Once(); foreach (var pair in settings) { Expect.Call(destination.SetSetting(pair.Key, pair.Value)).Return(true); } destination.EndBulkUpdate(); LastCall.On(destination).Repeat.Once(); // Meta-data (global) Expect.Call(destination.SetMetaDataItem(MetaDataItem.AccountActivationMessage, null, "AAM")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.PasswordResetProcedureMessage, null, "PRM")) .Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.LoginNotice, null, "")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.PageChangeMessage, null, "PCM")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.DiscussionChangeMessage, null, "DCM")).Return(true); // Meta-data (root) Expect.Call(destination.SetMetaDataItem(MetaDataItem.EditNotice, null, "")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.Footer, null, "FOOT")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.Header, null, "HEADER")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.HtmlHead, null, "HTML")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.PageFooter, null, "P_FOOT")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.PageHeader, null, "P_HEADER")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.Sidebar, null, "SIDEBAR")).Return(true); // Meta-data ("NS" namespace) Expect.Call(destination.SetMetaDataItem(MetaDataItem.EditNotice, "NS", "NS_EDIT")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.Footer, "NS", "NS_FOOT")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.Header, "NS", "NS_HEADER")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.HtmlHead, "NS", "NS_HTML")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.PageFooter, "NS", "NS_P_FOOT")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.PageHeader, "NS", "NS_P_HEADER")).Return(true); Expect.Call(destination.SetMetaDataItem(MetaDataItem.Sidebar, "NS", "NS_SIDEBAR")).Return(true); // Plugin assemblies Expect.Call(destination.StorePluginAssembly("Plugins1.dll", asm1)).Return(true); Expect.Call(destination.StorePluginAssembly("Plugins2.dll", asm2)).Return(true); // Plugin status Expect.Call(destination.SetPluginStatus("Test1.Plugin1", true)).Return(true); Expect.Call(destination.SetPluginStatus("Test2.Plugin2", false)).Return(true); // Plugin config Expect.Call(destination.SetPluginConfiguration("Test1.Plugin1", "Config1")).Return(true); Expect.Call(destination.SetPluginConfiguration("Test2.Plugin2", "")).Return(true); // Outgoing links foreach (var pair in outgoingLinks) { Expect.Call(destination.StoreOutgoingLinks(pair.Key, pair.Value)).Return(true); } // ACLs Expect.Call(destination.AclManager).Return(destinationAclManager).Repeat.Any(); foreach (var e in entries) { Expect.Call(destinationAclManager.StoreEntry(e.Resource, e.Action, e.Subject, e.Value)).Return(true); } mocks.ReplayAll(); DataMigrator.CopySettingsStorageProviderData(source, destination, new[] { "NS" }, new[] { "Test1.Plugin1", "Test2.Plugin2" }); mocks.VerifyAll(); }