diff options
author | Lluis Sanchez Gual <lluis@novell.com> | 2011-04-05 02:44:34 +0400 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@novell.com> | 2011-04-05 02:44:34 +0400 |
commit | 682278c3a8bf2b1e1a82b7a7c1eca7196b2aefb6 (patch) | |
tree | d744a8473528a63f3a3e005147604d277220994c /Test | |
parent | ffdb5b378ce97d8c896596140c1254dcd09e9fa1 (diff) |
Added tests for core add-in upgrades.
Diffstat (limited to 'Test')
-rw-r--r-- | Test/UnitTests/SampleAddins/AddRemoveTest1.addin.xml | 9 | ||||
-rw-r--r-- | Test/UnitTests/SampleAddins/AddRemoveTest2.addin.xml | 9 | ||||
-rw-r--r-- | Test/UnitTests/SimpleApp.addin.xml | 4 | ||||
-rw-r--r-- | Test/UnitTests/TestLoadUnload.cs | 8 | ||||
-rw-r--r-- | Test/UnitTests/TestSetupService.cs | 66 | ||||
-rw-r--r-- | Test/UnitTests/UnitTests.csproj | 7 | ||||
-rw-r--r-- | Test/UnitTests/test.addins | 1 |
7 files changed, 104 insertions, 0 deletions
diff --git a/Test/UnitTests/SampleAddins/AddRemoveTest1.addin.xml b/Test/UnitTests/SampleAddins/AddRemoveTest1.addin.xml new file mode 100644 index 0000000..b464b7c --- /dev/null +++ b/Test/UnitTests/SampleAddins/AddRemoveTest1.addin.xml @@ -0,0 +1,9 @@ +<Addin id="AddRemoveTest" namespace = "SimpleApp" version = "10.1"> + <Dependencies> + <Addin id="Core" version="0.1.0" /> + </Dependencies> + <Extension path="/SimpleApp/InstallUninstallTest"> + <Node label="10.1" /> + </Extension> +</Addin> + diff --git a/Test/UnitTests/SampleAddins/AddRemoveTest2.addin.xml b/Test/UnitTests/SampleAddins/AddRemoveTest2.addin.xml new file mode 100644 index 0000000..2ef8191 --- /dev/null +++ b/Test/UnitTests/SampleAddins/AddRemoveTest2.addin.xml @@ -0,0 +1,9 @@ +<Addin id="AddRemoveTest" namespace = "SimpleApp" version = "10.2"> + <Dependencies> + <Addin id="Core" version="0.1.0" /> + </Dependencies> + <Extension path="/SimpleApp/InstallUninstallTest"> + <Node label="10.2" /> + </Extension> +</Addin> + diff --git a/Test/UnitTests/SimpleApp.addin.xml b/Test/UnitTests/SimpleApp.addin.xml index c4e3076..4e123f4 100644 --- a/Test/UnitTests/SimpleApp.addin.xml +++ b/Test/UnitTests/SimpleApp.addin.xml @@ -54,6 +54,10 @@ <ExtensionNode name="WithAtt" type="UnitTests.NodeWithAttribute" /> </ExtensionPoint> + <ExtensionPoint path = "/SimpleApp/InstallUninstallTest"> + <ExtensionNode name="Node" type="UnitTests.ItemSetNode" /> + </ExtensionPoint> + <!-- Extensions --> <Extension path="/SimpleApp/NodeWithChildren"> diff --git a/Test/UnitTests/TestLoadUnload.cs b/Test/UnitTests/TestLoadUnload.cs index 9e7fa7c..4d5211f 100644 --- a/Test/UnitTests/TestLoadUnload.cs +++ b/Test/UnitTests/TestLoadUnload.cs @@ -207,5 +207,13 @@ namespace UnitTests XmlSerializer ser = new XmlSerializer (typeof(TestClass)); ser.Serialize (new StringWriter (), new TestClass ()); } + + [Test()] + public void TestLoadLatestVersion () + { + ExtensionNodeList list = AddinManager.GetExtensionNodes ("/SimpleApp/InstallUninstallTest"); + Assert.AreEqual (1, list.Count); + Assert.AreEqual ("10.2", ((ItemSetNode)list[0]).Label); + } } } diff --git a/Test/UnitTests/TestSetupService.cs b/Test/UnitTests/TestSetupService.cs index e6bc7be..d83fe67 100644 --- a/Test/UnitTests/TestSetupService.cs +++ b/Test/UnitTests/TestSetupService.cs @@ -238,6 +238,72 @@ namespace UnitTests setup.Repositories.RemoveRepository (repoUrl); } + + [Test] + public void UpgradeCoreAddin () + { + InitRepository (); + CreateTestPackage ("10.3"); + CreateTestPackage ("10.4"); + + ExtensionNodeList list = AddinManager.GetExtensionNodes ("/SimpleApp/InstallUninstallTest"); + Assert.AreEqual (1, list.Count); + Assert.AreEqual ("10.2", ((ItemSetNode)list[0]).Label); + + Addin adn = AddinManager.Registry.GetAddin ("SimpleApp.AddRemoveTest,10.2"); + Assert.IsTrue (adn.Enabled); + Assert.IsFalse (adn.Description.CanUninstall); // Core add-in can't be uninstalled + + setup.Repositories.RegisterRepository (monitor, repoUrl, true); + + var pkg = setup.Repositories.GetAvailableAddinUpdates ("SimpleApp.AddRemoveTest", RepositorySearchFlags.LatestVersionsOnly).FirstOrDefault (); + Assert.IsNotNull (pkg); + Assert.AreEqual ("SimpleApp.AddRemoveTest,10.4", pkg.Addin.Id); + + // Install the add-in + + setup.Install (new ConsoleProgressStatus (true), pkg); + + adn = AddinManager.Registry.GetAddin ("SimpleApp.AddRemoveTest,10.2"); + Assert.IsFalse (adn.Enabled); + + list = AddinManager.GetExtensionNodes ("/SimpleApp/InstallUninstallTest"); + Assert.AreEqual (1, list.Count); + Assert.AreEqual ("10.4", ((ItemSetNode)list[0]).Label); + + adn = AddinManager.Registry.GetAddin ("SimpleApp.AddRemoveTest"); + Assert.IsTrue (adn.Enabled); + Assert.IsTrue (adn.Description.CanUninstall); + + // Uninstall the add-in + + setup.Uninstall (new ConsoleProgressStatus (true), "SimpleApp.AddRemoveTest,10.4"); + + list = AddinManager.GetExtensionNodes ("/SimpleApp/InstallUninstallTest"); + Assert.AreEqual (0, list.Count); + + adn = AddinManager.Registry.GetAddin ("SimpleApp.AddRemoveTest"); + Assert.IsFalse (adn.Enabled); + + adn.Enabled = true; + + list = AddinManager.GetExtensionNodes ("/SimpleApp/InstallUninstallTest"); + Assert.AreEqual (1, list.Count); + Assert.AreEqual ("10.2", ((ItemSetNode)list[0]).Label); + } + + void CreateTestPackage (string newVersion) + { + string file = AddinManager.CurrentAddin.GetFilePath (Path.Combine ("SampleAddins","AddRemoveTest1.addin.xml")); + string txt = File.ReadAllText (file); + txt = txt.Replace ("10.1", newVersion); + + string tmpFile = Path.Combine (TempDir, "AddRemoveTest_" + newVersion + ".addin.xml"); + File.WriteAllText (tmpFile, txt); + + setup.BuildPackage (monitor, repoDir, tmpFile); + setup.BuildRepository (monitor, repoDir); + } } } diff --git a/Test/UnitTests/UnitTests.csproj b/Test/UnitTests/UnitTests.csproj index 1b145ce..b249227 100644 --- a/Test/UnitTests/UnitTests.csproj +++ b/Test/UnitTests/UnitTests.csproj @@ -92,6 +92,12 @@ <None Include="SupportFile.txt"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> + <None Include="SampleAddins\AddRemoveTest1.addin.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> + <None Include="SampleAddins\AddRemoveTest2.addin.xml"> + <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> + </None> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> @@ -115,6 +121,7 @@ </ProjectExtensions> <ItemGroup> <Folder Include="ExtensionModel\" /> + <Folder Include="SampleAddins\" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="TestManifest2.xml"> diff --git a/Test/UnitTests/test.addins b/Test/UnitTests/test.addins index c00d12d..ebd1db7 100644 --- a/Test/UnitTests/test.addins +++ b/Test/UnitTests/test.addins @@ -1,4 +1,5 @@ <Addins> <Directory>../../../lib</Directory> <Directory>../../../lib/extras</Directory> + <Directory>SampleAddins</Directory> </Addins> |