Beispiel #1
0
        public void CanAddSaveSolutionWithNestedProjectReferences()
        {
            CopyTestDataToPath("CsTestProject1.csproj", Path.Combine(_testDataPath, "sub", "p1"));
            CopyTestDataToPath("CsTestProject2.csproj", Path.Combine(_testDataPath, "sub", "p2"));
            CopyTestDataToPath("CsTestProject3.csproj", Path.Combine(_testDataPath, "p3", "sub"));

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            _scanningCommand.Start().Wait();

            Project project;

            _scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "p3", "sub", "CsTestProject3.csproj"), out project);

            var solution = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);

            solution.AddProject(project);

            // we need to change the Guid of the reference folder
            var refFolder = solution.SolutionItems.OfType <SolutionFolder>().First();

            refFolder.Guid = new Guid("{95374152-F021-4ABB-B317-74A183A89F00}");
            refFolder.Items.OfType <SolutionFolder>().First().Guid = new Guid("{CE1BA3BF-4957-4CBC-9D45-3DC68106B311}");

            var targetPath = Path.Combine(_testDataPath, "test.sln");

            var cmd = new SaveSolutionCommand(_settings, targetPath, VisualStudioVersion.VS2010, solution);

            cmd.Execute();

            Assert.AreEqual(ReadFromResource("CsTestProject3.sln"), File.ReadAllText(targetPath));
        }
Beispiel #2
0
        public void CanAddSaveSolutionWithProjectReferences()
        {
            CopyTestDataToPath("CsTestProject1.csproj", Path.Combine(_testDataPath, "p1"));
            CopyTestDataToPath("CsTestProject2.csproj", Path.Combine(_testDataPath, "p2"));

            var scanningCommand = new ScanningCommand(_testDataPath, true);

            scanningCommand.Start().Wait();

            Project project;

            scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "p2", "CsTestProject2.csproj"), out project);

            var solution = new SolutionViewModel(new DummyStatusMessenger(), _settings, _visualStudioInstallationsProvider, _testDataPath, scanningCommand.Projects);

            solution.AddProject(project);

            // we need to change the Guid of the reference folder
            solution.SolutionItems.OfType <SolutionFolder>().First().Guid = new Guid("{95374152-F021-4ABB-B317-74A183A89F00}");

            var targetPath = Path.Combine(_testDataPath, "test.sln");

            var cmd = new SaveSolutionCommand(_settings, _visualStudioInstallationsProvider, targetPath, "VS2010", solution);

            cmd.Execute();

            Assert.AreEqual(ReadFromResource("CsTestProject2.sln"), File.ReadAllText(targetPath));
        }
Beispiel #3
0
        public void CanReadProjectInSubdirectory()
        {
            CopyTestDataToPath("CsTestProject1.csproj", Path.Combine(_testDataPath, "dir"));

            var scanningCommand = new ScanningCommand(_testDataPath, true);
            var scanResult      = scanningCommand.Start().Result;

            Assert.AreEqual(Path.Combine(_testDataPath, "dir", "CsTestProject1.csproj"), scanResult.ProjectFolder.Projects[0].Filepath);
        }
Beispiel #4
0
        public void CanScanEmptyDirectory()
        {
            var scanningCommand = new ScanningCommand(_testDataPath, true);
            var scanResult      = scanningCommand.Start().Result;

            Assert.AreEqual(_testDataPath, scanResult.ProjectFolder.FullPath);
            Assert.AreEqual(_testDataFolderName, scanResult.ProjectFolder.Name);
            Assert.IsEmpty(scanResult.ProjectFolder.Folders);
            Assert.IsEmpty(scanResult.ProjectFolder.Projects);
        }
Beispiel #5
0
        public void CanReadProjectInRoot()
        {
            CopyTestDataToPath("CsTestProject1.csproj", _testDataPath);

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            var scanResult = _scanningCommand.Start().Result;

            Assert.AreEqual("CsTestProject1", scanResult.ProjectFolder.Projects[0].Name);
            Assert.AreEqual(Path.Combine(_testDataPath, "CsTestProject1.csproj"), scanResult.ProjectFolder.Projects[0].Filepath);
        }
Beispiel #6
0
        public void CanScanTwoProjectsInSubdirectories()
        {
            CopyTestDataToPath("CsTestProject1.csproj", Path.Combine(_testDataPath, "p1"));
            CopyTestDataToPath("CsTestProject2.csproj", Path.Combine(_testDataPath, "p2"));

            var scanningCommand = new ScanningCommand(_testDataPath, true);
            var scanResult      = scanningCommand.Start().Result;

            Assert.AreEqual(_testDataPath, scanResult.ProjectFolder.FullPath);
            Assert.AreEqual(_testDataFolderName, scanResult.ProjectFolder.Name);
            Assert.AreEqual(2, scanResult.ProjectFolder.Projects.Count);
        }
Beispiel #7
0
        public void EmptySubdirectoriesAreOmitted()
        {
            Directory.CreateDirectory(Path.Combine(_testDataPath, "YouShouldNotSeeMe"));

            var scanningCommand = new ScanningCommand(_testDataPath, true);
            var scanResult      = scanningCommand.Start().Result;

            Assert.AreEqual(_testDataPath, scanResult.ProjectFolder.FullPath);
            Assert.AreEqual(_testDataFolderName, scanResult.ProjectFolder.Name);
            Assert.IsEmpty(scanResult.ProjectFolder.Folders);
            Assert.IsEmpty(scanResult.ProjectFolder.Projects);
        }
Beispiel #8
0
        public void CanScanTwoProjectsInRoot()
        {
            CopyTestDataToPath("CsTestProject1.csproj", _testDataPath);
            CopyTestDataToPath("CsTestProject2.csproj", _testDataPath);

            var scanningCommand = new ScanningCommand(_testDataPath, true);
            var scanResult      = scanningCommand.Start().Result;

            Assert.AreEqual(_testDataPath, scanResult.ProjectFolder.FullPath);
            Assert.AreEqual(_testDataFolderName, scanResult.ProjectFolder.Name);
            Assert.IsEmpty(scanResult.ProjectFolder.Folders);
            Assert.AreEqual(2, scanResult.ProjectFolder.Projects.Count);
        }
        public void CanAddProject()
        {
            CopyTestDataToPath("CsTestProject1.csproj", _testDataPath);

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            _scanningCommand.Start().Wait();

            Project project;

            _scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "CsTestProject1.csproj"), out project);

            var sut = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);

            sut.AddProject(project);

            Assert.AreEqual(1, sut.SolutionItems.Count);
            Assert.AreEqual("CsTestProject1", sut.SolutionItems[0].Name);
            Assert.AreEqual(typeof(SolutionProject), sut.SolutionItems[0].GetType());
        }
Beispiel #10
0
        public void CanAddProject()
        {
            CopyTestDataToPath("CsTestProject1.csproj", _testDataPath);

            var scanningCommand = new ScanningCommand(_testDataPath, true);

            scanningCommand.Start().Wait();

            Project project;

            scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "CsTestProject1.csproj"), out project);

            var sut = new SolutionViewModel(new DummyStatusMessenger(), _settings, _visualStudioInstallationsProvider, _testDataPath, scanningCommand.Projects);

            sut.AddProject(project);

            Assert.AreEqual(1, sut.SolutionItems.Count);
            Assert.AreEqual("CsTestProject1", sut.SolutionItems[0].Name);
            Assert.AreEqual(typeof(SolutionProject), sut.SolutionItems[0].GetType());
        }
        public void CanAddProjectWithProjectReference()
        {
            CopyTestDataToPath("CsTestProject1.csproj", Path.Combine(_testDataPath, "p1"));
            CopyTestDataToPath("CsTestProject2.csproj", Path.Combine(_testDataPath, "p2"));

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            _scanningCommand.Start().Wait();

            Project project;

            _scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "p2", "CsTestProject2.csproj"), out project);

            var sut = new SolutionViewModel(_settings, _testDataPath, _scanningCommand.Projects);

            sut.AddProject(project);

            Assert.AreEqual(2, sut.SolutionItems.Count);
            Assert.AreEqual("_References", sut.SolutionItems[0].Name);
            Assert.AreEqual("CsTestProject2", sut.SolutionItems[1].Name);

            Assert.AreEqual(1, ((SolutionFolder)sut.SolutionItems[0]).Items.Count);
            Assert.AreEqual("CsTestProject1", ((SolutionFolder)sut.SolutionItems[0]).Items[0].Name);
        }
Beispiel #12
0
        public void CanAddSaveSolution()
        {
            CopyTestDataToPath("CsTestProject1.csproj", _testDataPath);

            _scanningCommand = new ScanningCommand(_testDataPath, true);
            _scanningCommand.Start().Wait();

            Project project;

            _scanningCommand.Projects.TryGetValue(Path.Combine(_testDataPath, "CsTestProject1.csproj"), out project);

            var solution = new SolutionViewModel(new DummyStatusMessenger(), _settings, _testDataPath, _scanningCommand.Projects);

            solution.AddProject(project);

            var targetPath = Path.Combine(_testDataPath, "test.sln");

            var cmd = new SaveSolutionCommand(_settings, targetPath, VisualStudioVersion.VS2010, solution);

            cmd.Execute();

            Assert.AreEqual(ReadFromResource("CsTestProject1.sln"), File.ReadAllText(targetPath));
        }