Represents a valid signature.
Inheritance: OpenPgpSignature, IFingerprintContainer
Beispiel #1
0
        public void TestExportFeeds()
        {
            using (var feedFile1 = new TemporaryFile("0install-unit-tests"))
            using (var feedFile2 = new TemporaryFile("0install-unit-tests"))
            {
                var feedCacheMock = CreateMock<IFeedCache>();

                feedCacheMock.Setup(x => x.GetPath(FeedTest.Sub1Uri)).Returns(feedFile1);
                feedCacheMock.Setup(x => x.GetPath(FeedTest.Sub2Uri)).Returns(feedFile2);

                var signature = new ValidSignature(123, new byte[0], new DateTime(2000, 1, 1));
                feedCacheMock.Setup(x => x.GetSignatures(FeedTest.Sub1Uri)).Returns(new OpenPgpSignature[] { signature });
                feedCacheMock.Setup(x => x.GetSignatures(FeedTest.Sub2Uri)).Returns(new OpenPgpSignature[] { signature });

                var openPgpMock = CreateMock<IOpenPgp>();
                openPgpMock.Setup(x => x.ExportKey(signature)).Returns("abc");

                _target.ExportFeeds(feedCacheMock.Object, openPgpMock.Object);

                string contentDir = Path.Combine(_destination, "content");
                FileAssert.AreEqual(
                    expected: new FileInfo(feedFile1),
                    actual: new FileInfo(Path.Combine(contentDir, FeedTest.Sub1Uri.PrettyEscape())),
                    message: "Feed should be exported.");
                FileAssert.AreEqual(
                    expected: new FileInfo(feedFile2),
                    actual: new FileInfo(Path.Combine(contentDir, FeedTest.Sub2Uri.PrettyEscape())),
                    message: "Feed should be exported.");

                File.ReadAllText(Path.Combine(contentDir, "000000000000007B.gpg")).Should()
                    .Be("abc", because: "GPG keys should be exported.");
            }
        }
 private bool Equals(ValidSignature other)
 {
     return base.Equals(other) && _fingerprint.SequencedEquals(other._fingerprint) && Timestamp == other.Timestamp;
 }
 private bool Equals(ValidSignature other)
 {
     return Timestamp.Equals(other.Timestamp) && string.Equals(Fingerprint, other.Fingerprint);
 }
 private bool Equals(ValidSignature other)
 => base.Equals(other) &&
 _fingerprint.SequencedEquals(other._fingerprint) &&
 Timestamp == other.Timestamp;