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); } }
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); }
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, "."); } }
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"); }
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"); } }