本文整理汇总了C#中NuGet.Test.Mocks.MockFileSystem.CreateDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# MockFileSystem.CreateDirectory方法的具体用法?C# MockFileSystem.CreateDirectory怎么用?C# MockFileSystem.CreateDirectory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NuGet.Test.Mocks.MockFileSystem
的用法示例。
在下文中一共展示了MockFileSystem.CreateDirectory方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindPackageFindTheRightPackage
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: GetPackagesReturnsAllValidPackages
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: MissingManifestFileThrows
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: AddRefreshFilesForAssembliesReferencesIncludeFilesUnderLibRoot
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: PackageDirectoriesAreMarkedForDeletionIsTrueWhenDeletemeFileInRootOfPackageRepository
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: PackageDirectoriesAreMarkedForDeletionIsFalsesWhenNoDeletemeFileInRootOfPackageRepository
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: EnsureManifestIsParsedCorrectly
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: ExistDoesNotCheckForPresenceOfManifestFileUnderDirectory
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: AddPackage
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: GetStreamReturnsCorrectContentWhenNupkgFileIsNestedInsidePackageFolder
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: CopyNativeBinariesForFilesUnderTheSameFolderName
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]);
}