コード例 #1
0
        public void AnalyzerInstaller_InstallMultiplePackages_Succeeds()
        {
            // Arrange

            // Create dummy NuGet package containing multiple assemblies
            string fakeRemotePackageSource = TestUtils.CreateTestSpecificFolder(this.TestContext, "fakeNuGetSource");
            LocalPackageRepository fakeRemoteRepo = new LocalPackageRepository(fakeRemotePackageSource);
            
            CreateAndInstallPackageWithDummyContent(fakeRemoteRepo, "package1", "1.0-rc1", "package1.dll");
            CreateAndInstallPackageWithDummyContent(fakeRemoteRepo, "package2", "22.2", "package2.dll");

            IEnumerable<NuGetPackageInfo> packages = new NuGetPackageInfo[] {
                new NuGetPackageInfo() { Id = "package1", Version = "1.0-rc1" },
                new NuGetPackageInfo() { Id = "package2", Version = "22.2" }
            };

            string localCacheDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "localInstallCache");
            AnalyzerInstaller testSubject = new AnalyzerInstaller(fakeRemotePackageSource, localCacheDir, new TestLogger());

            // Act
            IEnumerable<string> assemblyPaths = testSubject.InstallAssemblies(packages);

            // Assert
            AssertExpectedAssembliesReturned(assemblyPaths,
                "package1.dll",
                "package2.dll");
        }
コード例 #2
0
        public void AnalyzerInstaller_InstallMultiFilePackage_Succeeds()
        {
            // Arrange

            // Create dummy NuGet package containing multiple assemblies
            string fakeRemotePackageSource = TestUtils.CreateTestSpecificFolder(this.TestContext, "fakeNuGetSource");
            LocalPackageRepository fakeRemoteRepo = new LocalPackageRepository(fakeRemotePackageSource);

            PackageBuilder builder = CreatePackageBuilder("simplepackage1", "1.0.0");
            AddDummyFile(builder, "test.txt"); // not an assembly
            AddDummyFile(builder, "\\analyzer\\bbb.dll.xxx"); // not an assembly
            AddDummyFile(builder, "\\analyzer\\aaa.dll");
            AddDummyFile(builder, "\\supporting\\bbb.DLL");

            CreateAndInstallPackage(fakeRemoteRepo, builder);

            IEnumerable<NuGetPackageInfo> packages = new NuGetPackageInfo[] {
                new NuGetPackageInfo() { Id = "simplepackage1", Version = "1.0.0" }
            };

            string localCacheDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "localInstallCache");
            AnalyzerInstaller testSubject = new AnalyzerInstaller(fakeRemotePackageSource, localCacheDir, new TestLogger());

            // Act
            IEnumerable<string> assemblyPaths = testSubject.InstallAssemblies(packages);

            // Assert
            AssertExpectedAssembliesReturned(assemblyPaths,
                "\\analyzer\\aaa.dll",
                "\\supporting\\bbb.dll");
        }
コード例 #3
0
        public void AnalyzerInstaller_MissingPackage_Fails()
        {
            // Arrange

            // Create dummy NuGet package with the correct id but different version
            string fakeRemotePackageSource = TestUtils.CreateTestSpecificFolder(this.TestContext, "fakeNuGetSource");
            LocalPackageRepository fakeRemoteRepo = new LocalPackageRepository(fakeRemotePackageSource);
            CreateAndInstallPackageWithDummyContent(fakeRemoteRepo, "missing.package", "1.0.1", "dummy.txt");

            IEnumerable<NuGetPackageInfo> packages = new NuGetPackageInfo[] {
                new NuGetPackageInfo() { Id = "missing.package", Version = "1.0.0" }
            };

            string localCacheDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "localInstallCache");
            AnalyzerInstaller testSubject = new AnalyzerInstaller(fakeRemotePackageSource, localCacheDir, new TestLogger());

            // Act and assert
            AssertException.Expects<InvalidOperationException>(() => testSubject.InstallAssemblies(packages));
        }
コード例 #4
0
        [Ignore, WorkItem(209)] // https://jira.sonarsource.com/browse/SONARMSBRU-209 - should install analyzer dependencies
        public void AnalyzerInstaller_InstallPackageWithDependencies_Succeeds()
        {
            // Arrange

            // Create dummy NuGet packages
            string fakeRemotePackageSource = TestUtils.CreateTestSpecificFolder(this.TestContext, "fakeNuGetSource");
            LocalPackageRepository fakeRemoteRepo = new LocalPackageRepository(fakeRemotePackageSource);

            IPackage level3a = CreateAndInstallPackageWithDummyContent(fakeRemoteRepo, "level3a", "1.1", "\\file\\level3.dll");
            IPackage level3b = CreateAndInstallPackageWithDummyContent(fakeRemoteRepo, "level3b", "1.3", "\\file\\not a dll file so should be ignored");
            IPackage level2 = CreateAndInstallPackageWithDummyContent(fakeRemoteRepo, "level2a", "2.0", "\\aaa\\bbb\\level2.dll", level3a, level3b);
            CreateAndInstallPackageWithDummyContent(fakeRemoteRepo, "root.package", "2.1", "\\analyzer\\root.dll", level2);

            IEnumerable<NuGetPackageInfo> packages = new NuGetPackageInfo[] {
                new NuGetPackageInfo() { Id = "root.package", Version = "2.1" }
            };

            string localCacheDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "localInstallCache");
            AnalyzerInstaller testSubject = new AnalyzerInstaller(fakeRemotePackageSource, localCacheDir, new TestLogger());

            // Act
            IEnumerable<string> assemblyPaths = testSubject.InstallAssemblies(packages);

            // Assert
            AssertExpectedAssembliesReturned(assemblyPaths,
                "\\analyzer\\root.dll",
                "\\aaa\\bbb\\level2.dll",
                "\\file\\level3.dll");
        }
コード例 #5
0
        public void AnalyzerInstaller_NoPackagesSpecified_Succeeds()
        {
            // Arrange

            // No need to create dummy packages
            string fakeRemotePackageSource = TestUtils.CreateTestSpecificFolder(this.TestContext, "fakeNuGetSource");

            IEnumerable<NuGetPackageInfo> packages = new NuGetPackageInfo[] { };

            string localCacheDir = TestUtils.CreateTestSpecificFolder(this.TestContext, "localInstallCache");
            AnalyzerInstaller testSubject = new AnalyzerInstaller(fakeRemotePackageSource, localCacheDir, new TestLogger());

            // Act
            IEnumerable<string> assemblyPaths = testSubject.InstallAssemblies(packages);

            // Assert
            AssertExpectedAssembliesReturned(assemblyPaths /* none */ );
        }