public override void TestNormal() { var requirements = RequirementsTest.CreateTestRequirements(); var selections = SelectionsTest.CreateTestSelections(); var testFeed1 = FeedTest.CreateTestFeed(); testFeed1.Uri = FeedTest.Sub1Uri; testFeed1.Name = "Sub 1"; var testImplementation1 = testFeed1[selections.Implementations[0].ID]; FeedCacheMock.Setup(x => x.GetFeed(FeedTest.Sub1Uri)).Returns(testFeed1); var testImplementation2 = new Implementation { ID = "id2", ManifestDigest = new ManifestDigest(sha256: "abc"), Version = new ImplementationVersion("1.0") }; var testFeed2 = new Feed { Uri = FeedTest.Sub2Uri, Name = "Sub 2", Elements = { testImplementation2 } }; FeedCacheMock.Setup(x => x.GetFeed(FeedTest.Sub2Uri)).Returns(testFeed2); SolverMock.Setup(x => x.Solve(requirements)).Returns(selections); // Download uncached implementations StoreMock.Setup(x => x.Contains(It.IsAny <ManifestDigest>())).Returns(false); FetcherMock.Setup(x => x.Fetch(new[] { testImplementation1, testImplementation2 })); RunAndAssert(Resources.AllComponentsDownloaded, 0, selections, "http://0install.de/feeds/test/test1.xml", "--command=command", "--os=Windows", "--cpu=i586", "--not-before=1.0", "--before=2.0", "--version-for=http://0install.de/feeds/test/test2.xml", "2.0..!3.0"); }
public override void TestImportSelections() { var testFeed1 = FeedTest.CreateTestFeed(); testFeed1.Uri = FeedTest.Sub1Uri; testFeed1.Name = "Sub 1"; FeedCacheMock.Setup(x => x.GetFeed(FeedTest.Sub1Uri)).Returns(testFeed1); var testImplementation1 = (Implementation)testFeed1.Elements[0]; var testImplementation2 = new Implementation { ID = "id2", ManifestDigest = new ManifestDigest(sha256: "abc"), Version = new ImplementationVersion("1.0") }; var testFeed2 = new Feed { Uri = FeedTest.Sub2Uri, Name = "Sub 2", Elements = { testImplementation2 } }; FeedCacheMock.Setup(x => x.GetFeed(FeedTest.Sub2Uri)).Returns(testFeed2); var selections = SelectionsTest.CreateTestSelections(); // Download uncached implementations StoreMock.Setup(x => x.Contains(It.IsAny <ManifestDigest>())).Returns(false); FetcherMock.Setup(x => x.Fetch(new[] { testImplementation1, testImplementation2 })); using (var tempFile = new TemporaryFile("0install-unit-tests")) { selections.SaveXml(tempFile); RunAndAssert(Resources.AllComponentsDownloaded, 0, selections, tempFile); } }
public void Test() { StoreMock.Setup(x => x.Purge(Handler)); Handler.AnswerQuestionWith = true; RunAndAssert(null, ExitCode.OK); }
public void Pass() { StoreMock.Setup(x => x.Verify(_dummyDigest, Handler)); RunAndAssert(null, ExitCode.OK, _dummyDigest.Best !); }
public void Test() { StoreMock.Setup(x => x.Remove(_dummyDigest, Handler)).Returns(true); RunAndAssert(null, ExitCode.OK, _dummyDigest.Best !); }
public void MultipleArchives() { using var tempFile1 = new TemporaryFile("0install-unit-tests"); using var tempFile2 = new TemporaryFile("0install-unit-tests"); var digest = new ManifestDigest(sha256New: "abc"); string path1 = tempFile1; string path2 = tempFile2; StoreMock.Setup(x => x.AddArchives(new[] { new ArchiveFileInfo(path1, "mime1") { Extract = "extract1" }, new ArchiveFileInfo(path2, "mime2") { Extract = "extract2" } }, digest, Handler)).Returns(""); RunAndAssert(null, ExitCode.OK, "sha256new_" + digest.Sha256New, path1, "extract1", "mime1", path2, "extract2", "mime2"); }
public void Fail() { StoreMock.Setup(x => x.Verify(_dummyDigest, Handler)).Throws <DigestMismatchException>(); RunAndAssert(new DigestMismatchException().Message, ExitCode.DigestMismatch, _dummyDigest.Best !); }
public void TestOptimise() { StoreMock.Setup(x => x.Optimise(Resolve <ICommandHandler>())).Returns(123); RunAndAssert(string.Format(Resources.StorageReclaimed, FileUtils.FormatBytes(123, CultureInfo.CurrentCulture)), ExitCode.OK, "optimise"); }
public void Test() { StoreMock.Setup(x => x.GetPath(_dummyDigest)).Returns("path"); RunAndAssert("path", ExitCode.OK, "sha256new_abc"); }
public void Archive() { using var tempFile = new TemporaryFile("0install-test"); StoreMock.Setup(x => x.Add(_dummyDigest, It.IsAny <Action <IBuilder> >())); RunAndAssert(null, ExitCode.OK, _dummyDigest.Best !, tempFile, "extract", "mime"); }
public void Directory() { using var tempDir = new TemporaryDirectory("0install-test"); StoreMock.Setup(x => x.Add(_dummyDigest, It.IsAny <Action <IBuilder> >())); RunAndAssert(null, ExitCode.OK, _dummyDigest.Best !, tempDir); }
public void Normal() { using var tempDir = new TemporaryDirectory("0install-test-impl"); StoreMock.Setup(x => x.Add(_dummyDigest, It.IsAny <Action <IBuilder> >())); RunAndAssert(null, ExitCode.OK, Path.Combine(tempDir, _dummyDigest.Best !)); }
public void Test() { var digest = new ManifestDigest(sha256New: "abc"); StoreMock.Setup(x => x.Remove(digest, Handler)).Returns(true); RunAndAssert(null, ExitCode.OK, "sha256new_abc"); }
public void Test() { var digest = new ManifestDigest(sha256New: "abc"); StoreMock.Setup(x => x.GetPath(digest)).Returns("path"); RunAndAssert("path", ExitCode.OK, "sha256new_abc"); }
public void TestVerifyPass() { var digest = new ManifestDigest(sha256New: "abc"); StoreMock.Setup(x => x.Verify(digest, Resolve <ICommandHandler>())); RunAndAssert(null, ExitCode.OK, "verify", "sha256new_" + digest.Sha256New); }
public void Fail() { var digest = new ManifestDigest(sha256New: "abc"); StoreMock.Setup(x => x.Verify(digest, Handler)).Throws <DigestMismatchException>(); RunAndAssert(new DigestMismatchException().Message, ExitCode.DigestMismatch, "sha256new_" + digest.Sha256New); }
public void Pass() { var digest = new ManifestDigest(sha256New: "abc"); StoreMock.Setup(x => x.Verify(digest, Handler)); RunAndAssert(null, ExitCode.OK, "sha256new_" + digest.Sha256New); }
public void DownloadSingleArchiveMirror() { StoreMock.Setup(x => x.Flush()); using var mirrorServer = new MicroServer("archive/http/invalid/directory%23archive.zip", ZipArchiveStream); Config.FeedMirror = new FeedUri(mirrorServer.ServerUri); TestDownloadArchives( new Archive { Href = new Uri("http://invalid/directory/archive.zip"), MimeType = Archive.MimeTypeZip, Size = ZipArchiveStream.Length, Extract = "extract", Destination = "destination" }); }
public void Test() { var digest = new ManifestDigest(sha256New: "abc"); StoreMock.Setup(x => x.ListAll()).Returns(new[] { digest }); StoreMock.Setup(x => x.Remove(digest, Handler)).Returns(true); Handler.AnswerQuestionWith = true; RunAndAssert(null, ExitCode.OK); }
public void Normal() { using var tempDir = new TemporaryDirectory("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, path); }
public void DirectoryRelativePath() { using var tempDir = new TemporaryWorkingDirectory("0install-unit-tests"); var digest = new ManifestDigest(sha256New: "abc"); string path = tempDir; StoreMock.Setup(x => x.AddDirectory(path, digest, Handler)).Returns(""); RunAndAssert(null, ExitCode.OK, "sha256new_" + digest.Sha256New, "."); }
public void MultipleArchives() { using var tempFile1 = new TemporaryFile("0install-test"); using var tempFile2 = new TemporaryFile("0install-test"); StoreMock.Setup(x => x.Add(_dummyDigest, It.IsAny <Action <IBuilder> >())); RunAndAssert(null, ExitCode.OK, _dummyDigest.Best !, tempFile1, "extract1", "mime1", tempFile2, "extract2", "mime2"); }
public void ArchiveGuessMimeType() { using var tempDir = new TemporaryDirectory("0install-test"); string path = Path.Combine(tempDir, "archive.zip"); FileUtils.Touch(path); StoreMock.Setup(x => x.Add(_dummyDigest, It.IsAny <Action <IBuilder> >())); RunAndAssert(null, ExitCode.OK, _dummyDigest.Best !, path); }
public void TestAddDirectory() { using (var tempDir = new TemporaryDirectory("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, path); } }
public void TestCopyRelativePath() { 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, Resolve <ICommandHandler>())).Returns(""); RunAndAssert(null, ExitCode.OK, "copy", "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 TestAddArchive() { using (var tempFile = new TemporaryFile("0install-unit-tests")) { var digest = new ManifestDigest(sha256New: "abc"); string path = tempFile; StoreMock.Setup(x => x.AddArchives(new[] { new ArchiveFileInfo { Path = path } }, digest, Resolve <ICommandHandler>())).Returns(""); RunAndAssert(null, ExitCode.OK, "add", "sha256new_" + digest.Sha256New, path); } }
public void ArchiveExtract() { using (var tempFile = new TemporaryFile("0install-unit-tests")) { var digest = new ManifestDigest(sha256New: "abc"); string path = tempFile; StoreMock.Setup(x => x.AddArchives(new[] { new ArchiveFileInfo { Path = path, SubDir = "extract" } }, digest, Handler)).Returns(""); RunAndAssert(null, ExitCode.OK, "sha256new_" + digest.Sha256New, path, "extract"); } }
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"); } }
public override void TestNormal() { var requirements = RequirementsTest.CreateTestRequirements(); var selectionsOld = SelectionsTest.CreateTestSelections(); var selectionsNew = SelectionsTest.CreateTestSelections(); selectionsNew.Implementations[1].Version = new ImplementationVersion("2.0"); selectionsNew.Implementations.Add(new ImplementationSelection { InterfaceUri = FeedTest.Sub3Uri, ID = "id3", Version = new ImplementationVersion("0.1") }); SolverMock.SetupSequence(x => x.Solve(requirements)).Returns(selectionsOld).Returns(selectionsNew); var impl1 = new Implementation { ID = "id1" }; var impl2 = new Implementation { ID = "id2" }; var impl3 = new Implementation { ID = "id3" }; FeedCacheMock.Setup(x => x.GetFeed(FeedTest.Sub1Uri)).Returns(new Feed { Uri = FeedTest.Sub1Uri, Elements = { impl1 } }); FeedCacheMock.Setup(x => x.GetFeed(FeedTest.Sub2Uri)).Returns(new Feed { Uri = FeedTest.Sub2Uri, Elements = { impl2 } }); FeedCacheMock.Setup(x => x.GetFeed(FeedTest.Sub3Uri)).Returns(new Feed { Uri = FeedTest.Sub3Uri, Elements = { impl3 } }); // Download uncached implementations StoreMock.Setup(x => x.Contains(It.IsAny <ManifestDigest>())).Returns(false); FetcherMock.Setup(x => x.Fetch(new[] { impl1, impl2, impl3 }.IsEquivalent())); // Check for <replaced-by> FeedCacheMock.Setup(x => x.GetFeed(FeedTest.Test1Uri)).Returns(FeedTest.CreateTestFeed()); RunAndAssert("http://0install.de/feeds/test/test2.xml: 1.0 -> 2.0" + Environment.NewLine + "http://0install.de/feeds/test/sub3.xml: new -> 0.1", 0, selectionsNew, "http://0install.de/feeds/test/test1.xml", "--command=command", "--os=Windows", "--cpu=i586", "--not-before=1.0", "--before=2.0", "--version-for=http://0install.de/feeds/test/test2.xml", "2.0..!3.0"); }