CreateDirectory() public method

public CreateDirectory ( string path ) : void
path string
return void
コード例 #1
0
        public void FindPackageFindTheRightPackage()
        {
            // Arrange
            var fileSystem = new MockFileSystem("c:\\");
            AddPackage(fileSystem, "A", "1.0");
            AddPackage(fileSystem, "B", "1.0-alpha");
            AddPackage(fileSystem, "C", "2.0.1-RC");
            AddPackage(fileSystem, "D", "3.0");

            // these are invalid packages (missing corresponding directory)
            fileSystem.AddFile("AA.2.0.nupkg");
            fileSystem.AddFile("BB.4.0.nupkg");
            fileSystem.CreateDirectory("BB.3.0");

            var pathResolver = new DefaultPackagePathResolver("c:\\");
            var repository = new UnzippedPackageRepository(pathResolver, fileSystem);

            // Act
            var packageA = repository.FindPackage("A", new SemanticVersion("1.0"));
            var packageB = repository.FindPackage("B", new SemanticVersion("1.0-alpha"));

            // Assert
            AssertPackage(packageA, "A", new SemanticVersion("1.0"));
            AssertPackage(packageB, "B", new SemanticVersion("1.0.0-alpha"));
        }
コード例 #2
0
        public void GetPackagesReturnsAllValidPackages()
        {
            // Arrange
            var fileSystem = new MockFileSystem("c:\\");
            AddPackage(fileSystem, "A", "1.0");
            AddPackage(fileSystem, "B", "1.0-alpha");
            AddPackage(fileSystem, "C", "2.0.1-RC");
            AddPackage(fileSystem, "D", "3.0");

            // these are invalid packages (missing corresponding directory)
            fileSystem.AddFile("AA.2.0.nupkg");
            fileSystem.AddFile("BB.4.0.nupkg");
            fileSystem.CreateDirectory("BB.3.0");

            var pathResolver = new DefaultPackagePathResolver("c:\\");
            var repository = new UnzippedPackageRepository(pathResolver, fileSystem);

            // Act
            var packages = repository.GetPackages().ToList();

            // Assert
            Assert.Equal(4, packages.Count);
            AssertPackage(packages[0], "A", new SemanticVersion("1.0"));
            AssertPackage(packages[1], "B", new SemanticVersion("1.0.0-alpha"));
            AssertPackage(packages[2], "C", new SemanticVersion("2.0.1-RC"));
            AssertPackage(packages[3], "D", new SemanticVersion("3.0"));
        }
コード例 #3
0
        public void MissingManifestFileThrows()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.CreateDirectory("jQuery.2.0.0");
            fileSystem.AddFile("jQuery.2.0.0.nupkg");

            // Act & Assert
            Assert.Throws(typeof(InvalidOperationException), () => new UnzippedPackage(fileSystem, "jQuery.2.0.0"));
        }
コード例 #4
0
        public void AddRefreshFilesForAssembliesReferencesIncludeFilesUnderLibRoot()
        {
            // Arrange
            var projectSystem = new MockProjectSystem();
            var projectSystemFactory = new Mock<IProjectSystemFactory>();
            projectSystemFactory.Setup(p => p.CreateProjectSystem(It.IsAny<Project>(), It.IsAny<IFileSystemProvider>()))
                                .Returns(projectSystem);

            var websiteHandler = new VsWebsiteHandler(null, projectSystemFactory.Object);

            var packagesFileSystem = new MockFileSystem("x:\\some\\path");
            packagesFileSystem.CreateDirectory("A.1.0");
            packagesFileSystem.CreateDirectory("A.1.0\\lib");
            packagesFileSystem.AddFile("A.1.0\\lib\\one.dll");
            packagesFileSystem.AddFile("A.1.0\\lib\\two.winmd");

            packagesFileSystem.CreateDirectory("B.3.0.0-beta");
            packagesFileSystem.CreateDirectory("B.3.0.0-beta\\lib");
            packagesFileSystem.AddFile("B.3.0.0-beta\\lib\\three.dll");
            packagesFileSystem.AddFile("B.3.0.0-beta\\lib\\four.exe");

            var properties = new MockDteProperties();
            properties.AddProperty("FullPath", "x:\\project");
            properties.AddProperty("TargetFrameworkMoniker", ".NETFramework,Version=v4.0");

            var website = new Mock<Project>();
            website.Setup(p => p.Kind).Returns(VsConstants.WebSiteProjectTypeGuid);
            website.Setup(p => p.Properties).Returns(properties);

            // Act
            websiteHandler.AddRefreshFilesForReferences(
                website.Object, packagesFileSystem, new[] { new PackageName("A", new SemanticVersion("1.0")), 
                                                            new PackageName("B", new SemanticVersion("3.0.0-beta"))});

            // Assert
            Assert.True(projectSystem.DirectoryExists("bin"));
            var refreshFiles = projectSystem.GetFiles("bin", "*.refresh").OrderBy(s => s).ToList();
            Assert.Equal(4, refreshFiles.Count);
            Assert.Equal("bin\\four.exe.refresh", refreshFiles[0]);
            Assert.Equal("bin\\one.dll.refresh", refreshFiles[1]);
            Assert.Equal("bin\\three.dll.refresh", refreshFiles[2]);
            Assert.Equal("bin\\two.winmd.refresh", refreshFiles[3]);
        }
コード例 #5
0
        public void PackageDirectoriesAreMarkedForDeletionIsTrueWhenDeletemeFileInRootOfPackageRepository()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.CreateDirectory("A.1.0.0");
            fileSystem.AddFile("A.1.0.0.deleteme");

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem);

            // Assert
            Assert.True(deleteOnRestartManager.PackageDirectoriesAreMarkedForDeletion);
        }
コード例 #6
0
        public void PackageDirectoriesAreMarkedForDeletionIsFalsesWhenNoDeletemeFileInRootOfPackageRepository()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.CreateDirectory("A.1.0.0");
            fileSystem.AddFile("A.1.0.0");

            var deleteOnRestartManager = new DeleteOnRestartManager(() => fileSystem);

            // Act
            // Assert
            Assert.False(deleteOnRestartManager.GetPackageDirectoriesMarkedForDeletion().Any());
        }
コード例 #7
0
        public void EnsureManifestIsParsedCorrectly()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.AddFile("Jumpo.1.0.0.nupkg");
            fileSystem.CreateDirectory("Jumpo.1.0.0");
            fileSystem.AddFile("Jumpo.1.0.0\\Jumpo.1.0.0.nuspec", GetCompleteManifestContent());

            // Act
            var package = new UnzippedPackage(fileSystem, "Jumpo.1.0.0");

            // Assert
            Assert.Equal("Jumpo", package.Id);
            Assert.Equal(new SemanticVersion("1.0.0"), package.Version);
            Assert.Equal(1, package.Authors.Count());
            Assert.Equal("dotnetjunky", package.Authors.ElementAt(0));
            Assert.Equal(1, package.Owners.Count());
            Assert.Equal("Outercurve", package.Owners.ElementAt(0));
            Assert.Equal("http://www.nuget.com/license", package.LicenseUrl.ToString());
            Assert.Equal("http://www.nuget.com/", package.ProjectUrl.ToString());
            Assert.Equal("http://www.outercurve.com/", package.IconUrl.ToString());
            Assert.Equal(1, package.DependencySets.Count());
            Assert.Equal("bing", package.DependencySets.ElementAt(0).Dependencies.ElementAt(0).Id);
            Assert.Equal(new SemanticVersion("1.0-RC"), package.DependencySets.ElementAt(0).Dependencies.ElementAt(0).VersionSpec.MinVersion);
            Assert.True(package.DependencySets.ElementAt(0).Dependencies.ElementAt(0).VersionSpec.IsMinInclusive);
            Assert.Equal(null, package.DependencySets.ElementAt(0).Dependencies.ElementAt(0).VersionSpec.MaxVersion);
            Assert.False(package.DependencySets.ElementAt(0).Dependencies.ElementAt(0).VersionSpec.IsMaxInclusive);
            Assert.Equal("Jumpo Jet", package.Title);
            Assert.True(package.RequireLicenseAcceptance);
            Assert.Equal("My package description.", package.Description);
            Assert.Equal("This is jumpo package.", package.Summary);
            Assert.Equal("New jumpo.", package.ReleaseNotes);
            Assert.Equal("ar-EG", package.Language);
            Assert.Equal(" haha void ", package.Tags);
            Assert.Equal(1, package.FrameworkAssemblies.Count());
            Assert.Equal("System", package.FrameworkAssemblies.ElementAt(0).AssemblyName);
            Assert.Equal(1, package.FrameworkAssemblies.ElementAt(0).SupportedFrameworks.Count());
            Assert.Equal(
                new FrameworkName(".NETFramework", new Version("4.5")), 
                package.FrameworkAssemblies.ElementAt(0).SupportedFrameworks.ElementAt(0));
        }
コード例 #8
0
        public void ExistDoesNotCheckForPresenceOfManifestFileUnderDirectory(string id, string version, string path)
        {
            // Arrange
            var fileSystem = new MockFileSystem("x:\\root");
            fileSystem.CreateDirectory(path);
            fileSystem.AddFile(path + "\\" + path + ".nuspec");

            var configFileSystem = new MockFileSystem();
            var repository = new SharedPackageRepository(new DefaultPackagePathResolver(fileSystem), fileSystem, configFileSystem);

            // Act
            bool exists = repository.Exists(id, new SemanticVersion(version));

            // Assert
            Assert.True(exists);
        }
コード例 #9
0
 private void AddPackage(MockFileSystem fileSystem, string id, string version)
 {
     string packageName = id + "." + version;
     fileSystem.AddFile(packageName + Constants.PackageExtension, "aaa");
     fileSystem.CreateDirectory(packageName);
     fileSystem.AddFile(
         Path.Combine(packageName, packageName + Constants.ManifestExtension),
         CreatePackageManifestContent(id, version));
 }
コード例 #10
0
        public void GetStreamReturnsCorrectContentWhenNupkgFileIsNestedInsidePackageFolder()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.CreateDirectory("A.1.0.0");
            fileSystem.AddFile("A.1.0.0\\A.1.0.0.nupkg", "aaa");
            fileSystem.AddFile(
                "A.1.0.0\\A.1.0.0.nuspec",
                CreatePackageManifestContent("A", "1.0.0"));

            var package = new UnzippedPackage(fileSystem, "A.1.0.0");

            // Act
            Stream stream = package.GetStream();

            // Assert
            Assert.NotNull(stream);
            string content = stream.ReadToEnd();
            Assert.Equal("aaa", content);
        }
コード例 #11
0
        public void CopyNativeBinariesForFilesUnderTheSameFolderName()
        {
            // Arrange
            var projectSystem = new MockProjectSystem();
            var projectSystemFactory = new Mock<IProjectSystemFactory>();
            projectSystemFactory.Setup(p => p.CreateProjectSystem(It.IsAny<Project>(), It.IsAny<IFileSystemProvider>()))
                                .Returns(projectSystem);

            var websiteHandler = new VsWebsiteHandler(null, projectSystemFactory.Object);

            var packagesFileSystem = new MockFileSystem("x:\\some\\path");
            packagesFileSystem.CreateDirectory("A.1.0");
            packagesFileSystem.CreateDirectory("A.1.0\\nativebinaries");
            packagesFileSystem.AddFile("A.1.0\\NativeBinaries\\one.dll");
            packagesFileSystem.AddFile("A.1.0\\NativeBinaries\\two.winmd");

            packagesFileSystem.CreateDirectory("B.3.0.0-beta");
            packagesFileSystem.CreateDirectory("B.3.0.0-beta\\nativebinaries");
            packagesFileSystem.AddFile("B.3.0.0-beta\\nativebinaries\\three.txt");
            packagesFileSystem.AddFile("B.3.0.0-beta\\nativebinaries\\four.cd");
            packagesFileSystem.CreateDirectory("B.3.0.0-beta\\lib");
            packagesFileSystem.AddFile("B.3.0.0-beta\\lib\\forbidden.dll");

            var website = new Mock<Project>();
            website.Setup(p => p.Kind).Returns(VsConstants.WebSiteProjectTypeGuid);

            // Act
            websiteHandler.CopyNativeBinaries(
                website.Object, packagesFileSystem, new[] { new PackageName("A", new SemanticVersion("1.0")), 
                                                            new PackageName("B", new SemanticVersion("3.0.0-beta"))});

            // Assert
            Assert.True(projectSystem.DirectoryExists("bin"));
            var nativeBinaries = projectSystem.GetFiles("bin", "*.*").OrderBy(s => s).ToList();
            Assert.Equal(4, nativeBinaries.Count);
            Assert.Equal("bin\\four.cd", nativeBinaries[0]);
            Assert.Equal("bin\\one.dll", nativeBinaries[1]);
            Assert.Equal("bin\\three.txt", nativeBinaries[2]);
            Assert.Equal("bin\\two.winmd", nativeBinaries[3]);
        }