Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions test/Docfx.Build.Tests/XRefArchiveBuilderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@ public class XRefArchiveBuilderTest
[Fact]
public async Task TestDownload()
{
const string ZipFile = "test.zip";
var builder = new XRefArchiveBuilder();
var tempDirectory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
Directory.CreateDirectory(tempDirectory);

// Download following xrefmap.yml content.
// ```
// ### YamlMime:XRefMap
// sorted: true
// references: []
// ```
Assert.True(await builder.DownloadAsync(new Uri("http://dotnet.github.io/docfx/xrefmap.yml"), ZipFile));

using (var xar = XRefArchive.Open(ZipFile, XRefArchiveMode.Read))
try
{
var xrefMapFile = Path.Combine(tempDirectory, "xrefmap.yml");
var archiveFile = Path.Combine(tempDirectory, "test.zip");
await File.WriteAllTextAsync(
xrefMapFile,
"""
### YamlMime:XRefMap
sorted: true
references: []
""");

var builder = new XRefArchiveBuilder();
Assert.True(await builder.DownloadAsync(new Uri(xrefMapFile), archiveFile));

using var xar = XRefArchive.Open(archiveFile, XRefArchiveMode.Read);
var map = xar.GetMajor();
Assert.Null(map.HrefUpdated);
Assert.True(map.Sorted);
Assert.NotNull(map.References);
Assert.Null(map.Redirections);
}
File.Delete(ZipFile);
finally
{
Directory.Delete(tempDirectory, true);
}
}
}
Loading