当前位置: 首页>>代码示例>>C#>>正文


C# Recipe.Apply方法代码示例

本文整理汇总了C#中Recipe.Apply方法的典型用法代码示例。如果您正苦于以下问题:C# Recipe.Apply方法的具体用法?C# Recipe.Apply怎么用?C# Recipe.Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Recipe的用法示例。


在下文中一共展示了Recipe.Apply方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestApplyRecipeArchiv

        public void TestApplyRecipeArchiv()
        {
            using (var archiveFile = new TemporaryFile("0install-unit-tests"))
            {
                typeof(ExtractorTest).GetEmbedded("testArchive.zip").CopyToFile(archiveFile);

                var downloadedFiles = new[] {archiveFile};
                var recipe = new Recipe {Steps = {new Archive {MimeType = Archive.MimeTypeZip, Destination = "subDir"}}};

                using (TemporaryDirectory recipeDir = recipe.Apply(downloadedFiles, new SilentTaskHandler()))
                {
                    // /dest/symlink [S]
                    string path = new[] {recipeDir, "subDir", "symlink"}.Aggregate(Path.Combine);
                    Assert.IsTrue(File.Exists(path), "File should exist: " + path);
                    if (!UnixUtils.IsUnix) CollectionAssert.AreEquivalent(new[] {path}, FlagUtils.GetFiles(FlagUtils.SymlinkFile, recipeDir));

                    // /dest/subdir2/executable [deleted]
                    path = new[] {recipeDir, "subDir", "subdir2", "executable"}.Aggregate(Path.Combine);
                    Assert.IsTrue(File.Exists(path), "File should exist: " + path);
                    if (!UnixUtils.IsUnix) CollectionAssert.AreEquivalent(new[] {path}, FlagUtils.GetFiles(FlagUtils.XbitFile, recipeDir));
                }
            }
        }
开发者ID:modulexcite,项目名称:0install-win,代码行数:23,代码来源:RecipeUtilsTest.cs

示例2: TestApplyRecipeSingleFile

        public void TestApplyRecipeSingleFile()
        {
            using (var singleFile = new TemporaryFile("0install-unit-tests"))
            using (var archiveFile = new TemporaryFile("0install-unit-tests"))
            {
                File.WriteAllText(singleFile, "data");
                typeof(ArchiveExtractorTest).CopyEmbeddedToFile("testArchive.zip", archiveFile);

                var downloadedFiles = new[] {archiveFile, singleFile};
                var recipe = new Recipe {Steps = {new Archive {MimeType = Archive.MimeTypeZip}, new SingleFile {Destination = "subdir2/executable"}}};

                using (TemporaryDirectory recipeDir = recipe.Apply(downloadedFiles, new SilentTaskHandler()))
                {
                    // /subdir2/executable [!X]
                    string path = Path.Combine(recipeDir, "subdir2", "executable");
                    File.Exists(path).Should().BeTrue(because: "File should exist: " + path);
                    File.ReadAllText(path).Should().Be("data");
                    File.GetLastWriteTimeUtc(path).ToUnixTime()
                        .Should().Be(0, because: "Single files should be set to Unix epoch");
                    if (!UnixUtils.IsUnix) FlagUtils.GetFiles(FlagUtils.XbitFile, recipeDir).Should().BeEmpty();
                }
            }
        }
开发者ID:0install,项目名称:0install-win,代码行数:23,代码来源:RecipeUtilsTest.cs

示例3: TestApplyRecipeArchiv

        public void TestApplyRecipeArchiv()
        {
            using (var archiveFile = new TemporaryFile("0install-unit-tests"))
            {
                typeof(ArchiveExtractorTest).CopyEmbeddedToFile("testArchive.zip", archiveFile);

                var downloadedFiles = new[] {archiveFile};
                var recipe = new Recipe {Steps = {new Archive {MimeType = Archive.MimeTypeZip, Destination = "subDir"}}};

                using (TemporaryDirectory recipeDir = recipe.Apply(downloadedFiles, new SilentTaskHandler()))
                {
                    // /dest/symlink [S]
                    string path = Path.Combine(recipeDir, "subDir", "symlink");
                    File.Exists(path).Should().BeTrue(because: "File should exist: " + path);
                    if (UnixUtils.IsUnix) FileUtils.IsSymlink(path).Should().BeTrue();
                    else CygwinUtils.IsSymlink(path).Should().BeTrue();

                    // /dest/subdir2/executable [deleted]
                    path = Path.Combine(recipeDir, "subDir", "subdir2", "executable");
                    File.Exists(path).Should().BeTrue(because: "File should exist: " + path);
                    if (!UnixUtils.IsUnix) FlagUtils.GetFiles(FlagUtils.XbitFile, recipeDir).Should().BeEquivalentTo(path);
                }
            }
        }
开发者ID:0install,项目名称:0install-win,代码行数:24,代码来源:RecipeUtilsTest.cs

示例4: TestApplyRecipeRemove

        public void TestApplyRecipeRemove()
        {
            using (var archiveFile = new TemporaryFile("0install-unit-tests"))
            {
                typeof(ExtractorTest).GetEmbedded("testArchive.zip").CopyToFile(archiveFile);

                var downloadedFiles = new[] {archiveFile};
                var recipe = new Recipe
                {
                    Steps =
                    {
                        new Archive {MimeType = Archive.MimeTypeZip},
                        new RemoveStep {Path = "symlink"},
                        new RemoveStep {Path = "subdir2"}
                    }
                };

                using (TemporaryDirectory recipeDir = recipe.Apply(downloadedFiles, new SilentTaskHandler()))
                {
                    if (!UnixUtils.IsUnix)
                    {
                        Assert.IsEmpty(FlagUtils.GetFiles(FlagUtils.XbitFile, recipeDir));
                        Assert.IsEmpty(FlagUtils.GetFiles(FlagUtils.SymlinkFile, recipeDir));
                    }

                    // /symlink [deleted]
                    string path = Path.Combine(recipeDir, "symlink");
                    Assert.IsFalse(File.Exists(path), "File should not exist: " + path);

                    // /subdir2 [deleted]
                    path = Path.Combine(recipeDir, "subdir2");
                    Assert.IsFalse(Directory.Exists(path), "Directory should not exist: " + path);
                }
            }
        }
开发者ID:modulexcite,项目名称:0install-win,代码行数:35,代码来源:RecipeUtilsTest.cs

示例5: TestApplyRecipeSingleFile

        public void TestApplyRecipeSingleFile()
        {
            using (var singleFile = new TemporaryFile("0install-unit-tests"))
            using (var archiveFile = new TemporaryFile("0install-unit-tests"))
            {
                File.WriteAllText(singleFile, "data");
                typeof(ExtractorTest).GetEmbedded("testArchive.zip").CopyToFile(archiveFile);

                var downloadedFiles = new[] {archiveFile, singleFile};
                var recipe = new Recipe {Steps = {new Archive {MimeType = Archive.MimeTypeZip}, new SingleFile {Destination = "subdir2/executable"}}};

                using (TemporaryDirectory recipeDir = recipe.Apply(downloadedFiles, new SilentTaskHandler()))
                {
                    // /subdir2/executable [!X]
                    string path = new[] {recipeDir, "subdir2", "executable"}.Aggregate(Path.Combine);
                    Assert.IsTrue(File.Exists(path), "File should exist: " + path);
                    Assert.AreEqual("data", File.ReadAllText(path));
                    Assert.AreEqual(0, File.GetLastWriteTimeUtc(path).ToUnixTime(), "Single files should be set to Unix epoch");
                    if (!UnixUtils.IsUnix) Assert.IsEmpty(FlagUtils.GetFiles(FlagUtils.XbitFile, recipeDir));
                }
            }
        }
开发者ID:modulexcite,项目名称:0install-win,代码行数:22,代码来源:RecipeUtilsTest.cs

示例6: TestApplyRecipeRename

        public void TestApplyRecipeRename()
        {
            using (var archiveFile = new TemporaryFile("0install-unit-tests"))
            {
                typeof(ExtractorTest).GetEmbedded("testArchive.zip").CopyToFile(archiveFile);

                var downloadedFiles = new[] {archiveFile};
                var recipe = new Recipe
                {
                    Steps =
                    {
                        new Archive {MimeType = Archive.MimeTypeZip},
                        new RenameStep {Source = "symlink", Destination = "subdir3/symlink2"},
                        new RenameStep {Source = "subdir2/executable", Destination = "subdir2/executable2"}
                    }
                };

                using (TemporaryDirectory recipeDir = recipe.Apply(downloadedFiles, new SilentTaskHandler()))
                {
                    if (!UnixUtils.IsUnix)
                    {
                        CollectionAssert.AreEquivalent(
                            new[] {new[] {recipeDir, "subdir2", "executable2"}.Aggregate(Path.Combine)},
                            FlagUtils.GetFiles(FlagUtils.XbitFile, recipeDir));
                        CollectionAssert.AreEquivalent(
                            new[] {new[] {recipeDir, "subdir3", "symlink2"}.Aggregate(Path.Combine)},
                            FlagUtils.GetFiles(FlagUtils.SymlinkFile, recipeDir));
                    }

                    // /symlink [deleted]
                    string path = Path.Combine(recipeDir, "symlink");
                    Assert.IsFalse(File.Exists(path), "File should not exist: " + path);

                    // /subdir3/symlink2 [S]
                    path = new[] {recipeDir, "subdir3", "symlink2"}.Aggregate(Path.Combine);
                    Assert.IsTrue(File.Exists(path), "Missing file: " + path);
                    if (UnixUtils.IsUnix) Assert.IsTrue(FileUtils.IsSymlink(path), "Not symlink: " + path);

                    // /subdir2/executable [deleted]
                    path = new[] {recipeDir, "subdir2", "executable"}.Aggregate(Path.Combine);
                    Assert.IsFalse(File.Exists(path), "File should not exist: " + path);

                    // /subdir2/executable2 [X]
                    path = new[] {recipeDir, "subdir2", "executable2"}.Aggregate(Path.Combine);
                    Assert.IsTrue(File.Exists(path), "Missing file: " + path);
                    if (UnixUtils.IsUnix) Assert.IsTrue(FileUtils.IsExecutable(path), "Not executable: " + path);
                }
            }
        }
开发者ID:modulexcite,项目名称:0install-win,代码行数:49,代码来源:RecipeUtilsTest.cs


注:本文中的Recipe.Apply方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。