aspnetcore/test/Microsoft.Blazor.Mono.Test/MonoStaticFileProviderTest.cs

60 lines
1.8 KiB
C#

// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Xunit;
namespace Microsoft.Blazor.Mono.Test
{
public class MonoStaticFileProviderTest
{
[Fact]
public void SuppliesMonoFiles()
{
var provider = new MonoStaticFileProvider();
// This is not an exhaustive list. The set of BCL facade types is long and
// will probably change. This test is just to verify the resource embedding
// and filename mapping is working correctly.
var expectedFiles = new[]
{
"/asmjs/mono.asm.js",
"/asmjs/mono.js.mem",
"/wasm/mono.wasm",
"/bcl/mscorlib.dll",
"/bcl/Facades/System.Collections.dll",
};
foreach (var name in expectedFiles)
{
var fileInfo = provider.GetFileInfo(name);
Assert.True(fileInfo.Exists);
Assert.False(fileInfo.IsDirectory);
Assert.True(fileInfo.Length > 0);
}
}
[Fact]
public void DoesNotSupplyUnexpectedFiles()
{
var provider = new MonoStaticFileProvider();
var notExpectedFiles = new[]
{
"",
"mono",
"wasm",
"/wasm",
"/wasm/",
"wasm/mono.wasm",
"/wasm/../wasm/mono.wasm",
};
foreach (var name in notExpectedFiles)
{
var fileInfo = provider.GetFileInfo(name);
Assert.False(fileInfo.Exists);
}
}
}
}