Exemplo n.º 1
0
        public async Task TestSimpleCreation()
        {
            using (var project = Services.ProjectService.CreateDotNetProject("C#"))
                using (var workspace = await IdeApp.TypeSystemService.CreateEmptyWorkspace()) {
                    var map = new MonoDevelopWorkspace.ProjectDataMap(workspace);

                    var pid = map.GetId(project);
                    Assert.IsNull(pid);

                    pid = map.GetOrCreateId(project, null);
                    Assert.IsNotNull(pid);

                    var projectInMap = map.GetMonoProject(pid);
                    Assert.AreSame(project, projectInMap);

                    var projectRemovedFromMap = map.RemoveProject(pid);
                    Assert.AreSame(projectInMap, projectRemovedFromMap);

                    Assert.IsNull(map.GetId(project));

                    pid = map.GetOrCreateId(project, null);
                    map.RemoveProject(project);

                    Assert.IsNull(map.GetId(project));
                }
        }
Exemplo n.º 2
0
        public async Task TestSimpleCreation_MultiTargetFramework()
        {
            var projectFile = Util.GetSampleProject("multi-target", "multi-target.csproj");

            using (var project = (DotNetProject)await Services.ProjectService.ReadSolutionItem(Util.GetMonitor(), projectFile))
                using (var workspace = await IdeApp.TypeSystemService.CreateEmptyWorkspace()) {
                    var map = new MonoDevelopWorkspace.ProjectDataMap(workspace);

                    var pid = map.GetOrCreateId(project, null, "netcoreapp1.1");
                    Assert.IsNotNull(pid);

                    var pid2 = map.GetOrCreateId(project, null, "netstandard1.0");
                    Assert.IsNotNull(pid2);

                    Assert.AreNotEqual(pid, pid2);

                    // Returns first project for first framework
                    var defaultPid = map.GetId(project);
                    Assert.IsNotNull(defaultPid);
                    Assert.AreEqual("multi-target (netcoreapp1.1)", defaultPid.DebugName);
                    Assert.AreEqual(defaultPid, pid);

                    var pids = map.GetIds(project);
                    Assert.AreEqual(2, pids.Length);
                    Assert.That(pids, Contains.Item(pid));
                    Assert.That(pids, Contains.Item(pid2));

                    var projectInMap = map.GetMonoProject(pid);
                    Assert.AreSame(project, projectInMap);

                    projectInMap = map.GetMonoProject(pid2);
                    Assert.AreSame(project, projectInMap);

                    var foundPid = map.GetId(project, "netcoreapp1.1");
                    Assert.AreSame(pid, foundPid);

                    foundPid = map.GetId(project, "netstandard1.0");
                    Assert.AreSame(pid2, foundPid);

                    var projectRemovedFromMap = map.RemoveProject(pid);
                    Assert.AreSame(projectInMap, projectRemovedFromMap);

                    projectRemovedFromMap = map.RemoveProject(pid2);
                    Assert.AreSame(projectInMap, projectRemovedFromMap);

                    Assert.IsNull(map.GetId(project, "netcoreapp1.1"));
                    Assert.IsNull(map.GetId(project, "netstandard1.0"));

                    pid = map.GetOrCreateId(project, null, "netcoreapp1.1");
                    map.RemoveProject(project);

                    Assert.IsNull(map.GetId(project, "netcoreapp1.1"));

                    pid = map.GetOrCreateId(project, null, "netstandard1.0");
                    map.RemoveProject(project);

                    Assert.IsNull(map.GetId(project, "netstandard1.0"));
                }
        }
        public void TestSimpleCreation()
        {
            using (var project = Services.ProjectService.CreateDotNetProject("C#"))
                using (var workspace = new MonoDevelopWorkspace(null)) {
                    var map = new MonoDevelopWorkspace.ProjectDataMap(workspace);

                    var pid = map.GetId(project);
                    Assert.IsNull(pid);

                    pid = map.GetOrCreateId(project, null);
                    Assert.IsNotNull(pid);

                    var projectInMap = map.GetMonoProject(pid);
                    Assert.AreSame(project, projectInMap);

                    map.RemoveProject(project, pid);
                    Assert.IsNull(map.GetId(project));
                }
        }