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