public static void CheckGenericItemProject (string fileFormat) { Solution sol = new Solution (); sol.ConvertToFormat (Services.ProjectService.FileFormats.GetFileFormat (fileFormat), true); string dir = Util.CreateTmpDir ("generic-item-" + fileFormat); sol.FileName = Path.Combine (dir, "TestGenericItem"); sol.Name = "TheItem"; GenericItem it = new GenericItem (); it.SomeValue = "hi"; sol.RootFolder.Items.Add (it); it.FileName = Path.Combine (dir, "TheItem"); it.Name = "TheItem"; sol.Save (Util.GetMonitor ()); Solution sol2 = (Solution) Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), sol.FileName); Assert.AreEqual (1, sol2.Items.Count); Assert.IsTrue (sol2.Items [0] is GenericItem); it = (GenericItem) sol2.Items [0]; Assert.AreEqual ("hi", it.SomeValue); }
public static async Task CheckGenericItemProject (MSBuildFileFormat format) { Solution sol = new Solution (); sol.ConvertToFormat (format); string dir = Util.CreateTmpDir ("generic-item-" + format.Name); sol.FileName = Path.Combine (dir, "TestGenericItem"); sol.Name = "TheItem"; MonoDevelop.Projects.MSBuild.MSBuildProjectService.RegisterGenericProjectType ("GenericItem", typeof(GenericItem)); GenericItem it = new GenericItem (); it.SomeValue = "hi"; sol.RootFolder.Items.Add (it); it.FileName = Path.Combine (dir, "TheItem"); it.Name = "TheItem"; await sol.SaveAsync (Util.GetMonitor ()); Solution sol2 = (Solution) await Services.ProjectService.ReadWorkspaceItem (Util.GetMonitor (), sol.FileName); Assert.AreEqual (1, sol2.Items.Count); Assert.IsInstanceOf<GenericItem> (sol2.Items [0]); it = (GenericItem) sol2.Items [0]; Assert.AreEqual ("hi", it.SomeValue); }