async Task TestAll(MockProject project, Workspace ws)
        {
            await FileWatcherService.Update();

            foreach (var toClear in ws.GetAllItems <MockProject> ())
            {
                toClear.Reset();
            }

            var testFile = project.BaseDirectory.Combine("test_file");

            // Create -> Change -> Rename -> Delete
            File.WriteAllText(testFile, "");
            File.Move(testFile, testFile + 2);
            File.Delete(testFile + 2);

            await WaitForFilesRemoved(new FilePath[] { testFile, testFile + 2 });
        }
예제 #2
0
        public void ModelQueries()
        {
            DotNetProject     it2, it3, it4;
            DummySolutionItem it1;
            string            someFile, someId;

            Workspace ws  = new Workspace();
            Workspace cws = new Workspace();

            ws.Items.Add(cws);

            Solution sol1 = new Solution();

            cws.Items.Add(sol1);
            sol1.RootFolder.Items.Add(it1 = new DummySolutionItem());
            sol1.RootFolder.Items.Add(it2 = new DotNetAssemblyProject("C#"));

            Solution sol2 = new Solution();

            cws.Items.Add(sol2);
            SolutionFolder f = new SolutionFolder();

            sol2.RootFolder.Items.Add(f);
            f.Items.Add(it3 = new DotNetAssemblyProject("C#"));
            f.Items.Add(it4 = new DotNetAssemblyProject("C#"));

            it3.Name     = "it3";
            it4.FileName = "/test/it4";
            someFile     = it4.FileName;
            someId       = it3.ItemId;
            Assert.IsFalse(string.IsNullOrEmpty(someId));

            Assert.AreEqual(2, sol1.Items.Count);
            Assert.IsTrue(sol1.Items.Contains(it1));
            Assert.IsTrue(sol1.Items.Contains(it2));

            Assert.AreEqual(2, sol2.Items.Count);
            Assert.IsTrue(sol2.Items.Contains(it3));
            Assert.IsTrue(sol2.Items.Contains(it4));

            ReadOnlyCollection <SolutionItem> its = ws.GetAllSolutionItems();

            Assert.AreEqual(7, its.Count);
            Assert.IsTrue(its.Contains(it1));
            Assert.IsTrue(its.Contains(it2));
            Assert.IsTrue(its.Contains(it3));
            Assert.IsTrue(its.Contains(it4));
            Assert.IsTrue(its.Contains(sol1.RootFolder));
            Assert.IsTrue(its.Contains(sol2.RootFolder));
            Assert.IsTrue(its.Contains(f));

            ReadOnlyCollection <DotNetProject> its2 = ws.GetAllSolutionItems <DotNetProject> ();

            Assert.AreEqual(3, its2.Count);
            Assert.IsTrue(its2.Contains(it2));
            Assert.IsTrue(its2.Contains(it3));
            Assert.IsTrue(its2.Contains(it4));

            ReadOnlyCollection <Project> its3 = ws.GetAllProjects();

            Assert.AreEqual(3, its3.Count);
            Assert.IsTrue(its3.Contains(it2));
            Assert.IsTrue(its3.Contains(it3));
            Assert.IsTrue(its3.Contains(it4));

            ReadOnlyCollection <Solution> its4 = ws.GetAllSolutions();

            Assert.AreEqual(2, its4.Count);
            Assert.IsTrue(its4.Contains(sol1));
            Assert.IsTrue(its4.Contains(sol2));

            ReadOnlyCollection <WorkspaceItem> its5 = ws.GetAllItems();

            Assert.AreEqual(4, its5.Count);
            Assert.IsTrue(its5.Contains(ws));
            Assert.IsTrue(its5.Contains(cws));
            Assert.IsTrue(its5.Contains(sol2));
            Assert.IsTrue(its5.Contains(sol2));

            ReadOnlyCollection <Workspace> its6 = ws.GetAllItems <Workspace> ();

            Assert.AreEqual(2, its6.Count);
            Assert.IsTrue(its6.Contains(ws));
            Assert.IsTrue(its6.Contains(cws));

            SolutionEntityItem fi = ws.FindSolutionItem(someFile);

            Assert.AreEqual(it4, fi);

            fi = ws.FindSolutionItem(someFile + ".wrong");
            Assert.IsNull(fi);

            SolutionItem si = sol2.GetSolutionItem(someId);

            Assert.AreEqual(it3, si);

            fi = sol2.FindSolutionItem(someFile);
            Assert.AreEqual(it4, fi);

            fi = sol2.FindProjectByName("it3");
            Assert.AreEqual(it3, fi);

            fi = sol2.FindProjectByName("it4");
            Assert.AreEqual(it4, fi);

            fi = sol2.FindProjectByName("it2");
            Assert.IsNull(fi);
        }
예제 #3
0
        public void ModelQueries()
        {
            DotNetProject     it2, it3, it4;
            DummySolutionItem it1;
            string            someFile, someId;

            Workspace ws  = new Workspace();
            Workspace cws = new Workspace();

            ws.Items.Add(cws);

            Solution sol1 = new Solution();

            cws.Items.Add(sol1);
            sol1.RootFolder.Items.Add(it1 = new DummySolutionItem());
            sol1.RootFolder.Items.Add(it2 = Services.ProjectService.CreateDotNetProject("C#"));

            Solution sol2 = new Solution();

            cws.Items.Add(sol2);
            SolutionFolder f = new SolutionFolder();

            sol2.RootFolder.Items.Add(f);
            f.Items.Add(it3 = Services.ProjectService.CreateDotNetProject("C#"));
            f.Items.Add(it4 = Services.ProjectService.CreateDotNetProject("C#"));

            it3.Name     = "it3";
            it4.FileName = "/test/it4";
            someFile     = it4.FileName;
            someId       = it3.ItemId;
            Assert.IsFalse(string.IsNullOrEmpty(someId));

            Assert.AreEqual(2, sol1.Items.Count);
            Assert.IsTrue(sol1.Items.Contains(it1));
            Assert.IsTrue(sol1.Items.Contains(it2));

            Assert.AreEqual(2, sol2.Items.Count);
            Assert.IsTrue(sol2.Items.Contains(it3));
            Assert.IsTrue(sol2.Items.Contains(it4));

            var its = ws.GetAllItems <SolutionFolderItem> ().ToList();

            Assert.AreEqual(7, its.Count);
            Assert.IsTrue(its.Contains(it1));
            Assert.IsTrue(its.Contains(it2));
            Assert.IsTrue(its.Contains(it3));
            Assert.IsTrue(its.Contains(it4));
            Assert.IsTrue(its.Contains(sol1.RootFolder));
            Assert.IsTrue(its.Contains(sol2.RootFolder));
            Assert.IsTrue(its.Contains(f));

            var its2 = ws.GetAllItems <DotNetProject> ().ToList();

            Assert.AreEqual(3, its2.Count);
            Assert.IsTrue(its2.Contains(it2));
            Assert.IsTrue(its2.Contains(it3));
            Assert.IsTrue(its2.Contains(it4));

            var its3 = ws.GetAllItems <Project> ().ToList();

            Assert.AreEqual(3, its3.Count);
            Assert.IsTrue(its3.Contains(it2));
            Assert.IsTrue(its3.Contains(it3));
            Assert.IsTrue(its3.Contains(it4));

            var its4 = ws.GetAllItems <Solution> ().ToList();

            Assert.AreEqual(2, its4.Count);
            Assert.IsTrue(its4.Contains(sol1));
            Assert.IsTrue(its4.Contains(sol2));

            var its5 = ws.GetAllItems <WorkspaceItem> ().ToList();

            Assert.AreEqual(4, its5.Count);
            Assert.IsTrue(its5.Contains(ws));
            Assert.IsTrue(its5.Contains(cws));
            Assert.IsTrue(its5.Contains(sol2));
            Assert.IsTrue(its5.Contains(sol2));

            var its6 = ws.GetAllItems <Workspace> ().ToList();

            Assert.AreEqual(2, its6.Count);
            Assert.IsTrue(its6.Contains(ws));
            Assert.IsTrue(its6.Contains(cws));

            SolutionFolderItem si = sol2.GetSolutionItem(someId);

            Assert.AreEqual(it3, si);

            SolutionItem fi = sol2.FindSolutionItem(someFile);

            Assert.AreEqual(it4, fi);

            fi = sol2.FindProjectByName("it3");
            Assert.AreEqual(it3, fi);

            fi = sol2.FindProjectByName("it4");
            Assert.AreEqual(it4, fi);

            fi = sol2.FindProjectByName("it2");
            Assert.IsNull(fi);

            ws.Dispose();
            cws.Dispose();
        }
		public void ModelQueries ()
		{
			DotNetProject it2, it3, it4;
			DummySolutionItem it1;
			string someFile, someId;
			
			Workspace ws = new Workspace ();
			Workspace cws = new Workspace ();
			ws.Items.Add (cws);
			
			Solution sol1 = new Solution ();
			cws.Items.Add (sol1);
			sol1.RootFolder.Items.Add (it1 = new DummySolutionItem ());
			sol1.RootFolder.Items.Add (it2 = Services.ProjectService.CreateDotNetProject ("C#"));
			
			Solution sol2 = new Solution ();
			cws.Items.Add (sol2);
			SolutionFolder f = new SolutionFolder ();
			sol2.RootFolder.Items.Add (f);
			f.Items.Add (it3 = Services.ProjectService.CreateDotNetProject ("C#"));
			f.Items.Add (it4 = Services.ProjectService.CreateDotNetProject ("C#"));
			
			it3.Name = "it3";
			it4.FileName = "/test/it4";
			someFile = it4.FileName;
			someId = it3.ItemId;
			Assert.IsFalse (string.IsNullOrEmpty (someId));
			
			Assert.AreEqual (2, sol1.Items.Count);
			Assert.IsTrue (sol1.Items.Contains (it1));
			Assert.IsTrue (sol1.Items.Contains (it2));
			
			Assert.AreEqual (2, sol2.Items.Count);
			Assert.IsTrue (sol2.Items.Contains (it3));
			Assert.IsTrue (sol2.Items.Contains (it4));
			
			var its = ws.GetAllItems<SolutionFolderItem> ().ToList();
			Assert.AreEqual (7, its.Count);
			Assert.IsTrue (its.Contains (it1));
			Assert.IsTrue (its.Contains (it2));
			Assert.IsTrue (its.Contains (it3));
			Assert.IsTrue (its.Contains (it4));
			Assert.IsTrue (its.Contains (sol1.RootFolder));
			Assert.IsTrue (its.Contains (sol2.RootFolder));
			Assert.IsTrue (its.Contains (f));
			
			var its2 = ws.GetAllItems<DotNetProject> ().ToList();
			Assert.AreEqual (3, its2.Count);
			Assert.IsTrue (its2.Contains (it2));
			Assert.IsTrue (its2.Contains (it3));
			Assert.IsTrue (its2.Contains (it4));
			
			var its3 = ws.GetAllItems<Project> ().ToList();
			Assert.AreEqual (3, its3.Count);
			Assert.IsTrue (its3.Contains (it2));
			Assert.IsTrue (its3.Contains (it3));
			Assert.IsTrue (its3.Contains (it4));
			
			var its4 = ws.GetAllItems<Solution> ().ToList();
			Assert.AreEqual (2, its4.Count);
			Assert.IsTrue (its4.Contains (sol1));
			Assert.IsTrue (its4.Contains (sol2));
			
			var its5 = ws.GetAllItems<WorkspaceItem> ().ToList();
			Assert.AreEqual (4, its5.Count);
			Assert.IsTrue (its5.Contains (ws));
			Assert.IsTrue (its5.Contains (cws));
			Assert.IsTrue (its5.Contains (sol2));
			Assert.IsTrue (its5.Contains (sol2));
			
			var its6 = ws.GetAllItems<Workspace> ().ToList();
			Assert.AreEqual (2, its6.Count);
			Assert.IsTrue (its6.Contains (ws));
			Assert.IsTrue (its6.Contains (cws));
			
			SolutionFolderItem si = sol2.GetSolutionItem (someId);
			Assert.AreEqual (it3, si);
			
			SolutionItem fi = sol2.FindSolutionItem (someFile);
			Assert.AreEqual (it4, fi);
			
			fi = sol2.FindProjectByName ("it3");
			Assert.AreEqual (it3, fi);
			
			fi = sol2.FindProjectByName ("it4");
			Assert.AreEqual (it4, fi);
			
			fi = sol2.FindProjectByName ("it2");
			Assert.IsNull (fi);
		}