Esempio n. 1
0
        public void TestGetFilesRelative()
        {
            using (var tempDir = new TemporaryWorkingDirectory("unit-tests"))
            {
                File.WriteAllText("a.txt", @"a");
                File.WriteAllText("b.txt", @"b");
                File.WriteAllText("c.inf", @"c");
                File.WriteAllText("d.nfo", @"d");

                const string subdirPath = "dir";
                Directory.CreateDirectory(subdirPath);
                File.WriteAllText(Path.Combine(subdirPath, "1.txt"), @"1");
                File.WriteAllText(Path.Combine(subdirPath, "2.inf"), @"a");

                var result = ArgumentUtils.GetFiles(new[]
                {
                    "*.txt",   // Wildcard
                    "d.nfo",   // Specifc file
                    subdirPath // Directory with implict default wildcard
                }, "*.txt");
                result[0].FullName.Should().Be(Path.Combine(tempDir, "a.txt"));
                result[1].FullName.Should().Be(Path.Combine(tempDir, "b.txt"));
                result[2].FullName.Should().Be(Path.Combine(tempDir, "d.nfo"));
                Path.Combine(tempDir, subdirPath, "1.txt").Should().Be(result[3].FullName);
            }
        }
Esempio n. 2
0
            public void RelativePath()
            {
                using var tempDir = new TemporaryWorkingDirectory("0install-unit-tests");
                var    digest = new ManifestDigest(sha256New: "abc");
                string path   = Path.Combine(tempDir, "sha256new_" + digest.Sha256New);

                StoreMock.Setup(x => x.AddDirectory(path, digest, Handler)).Returns("");

                RunAndAssert(null, ExitCode.OK,
                             "sha256new_" + digest.Sha256New);
            }
Esempio n. 3
0
        public void TestAddDirectoryRelativePath()
        {
            using (var tempDir = new TemporaryWorkingDirectory("0install-unit-tests"))
            {
                var    digest = new ManifestDigest(sha256New: "abc");
                string path   = tempDir;
                StoreMock.Setup(x => x.AddDirectory(path, digest, Resolve <ICommandHandler>())).Returns("");

                RunAndAssert(null, ExitCode.OK,
                             "add", "sha256new_" + digest.Sha256New, ".");
            }
        }
Esempio n. 4
0
            public void ArchiveRelativePathGuessMimeType()
            {
                using var tempDir = new TemporaryWorkingDirectory("0install-unit-tests");
                var    digest = new ManifestDigest(sha256New: "abc");
                string path   = Path.Combine(tempDir, "archive.zip");

                File.WriteAllText(path, "xyz");
                StoreMock.Setup(x => x.AddArchives(new[]
                {
                    new ArchiveFileInfo(path, Model.Archive.MimeTypeZip)
                }, digest, Handler)).Returns("");

                RunAndAssert(null, ExitCode.OK,
                             "sha256new_" + digest.Sha256New, "archive.zip");
            }
Esempio n. 5
0
        public void TestAddArchiveRelativePath()
        {
            using (var tempDir = new TemporaryWorkingDirectory("0install-unit-tests"))
            {
                var    digest = new ManifestDigest(sha256New: "abc");
                string path   = Path.Combine(tempDir, "archive");
                File.WriteAllText(path, "xyz");
                StoreMock.Setup(x => x.AddArchives(new[]
                {
                    new ArchiveFileInfo {
                        Path = path
                    }
                }, digest, Resolve <ICommandHandler>())).Returns("");

                RunAndAssert(null, ExitCode.OK,
                             "add", "sha256new_" + digest.Sha256New, "archive");
            }
        }