1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:07:52 +08:00

Use embedded resources for test assets

This commit is contained in:
Drew DeVault 2016-10-10 09:49:54 -04:00 committed by Dean Herbert
parent 30f2eeda7c
commit 34b24e1399
3 changed files with 12 additions and 9 deletions

View File

@ -19,7 +19,7 @@ namespace osu.Game.Tests.Beatmaps.IO
[Test]
public void TestReadBeatmaps()
{
using (var osz = File.OpenRead(Resource.GetPath("241526 Soleily - Renatus.osz")))
using (var osz = Resource.OpenResource("241526 Soleily - Renatus.osz"))
{
var reader = new OszArchiveReader(osz);
string[] expected =
@ -46,7 +46,7 @@ namespace osu.Game.Tests.Beatmaps.IO
[Test]
public void TestReadMetadata()
{
using (var osz = File.OpenRead(Resource.GetPath("241526 Soleily - Renatus.osz")))
using (var osz = Resource.OpenResource("241526 Soleily - Renatus.osz"))
{
var reader = new OszArchiveReader(osz);
var meta = reader.ReadMetadata();
@ -66,7 +66,7 @@ namespace osu.Game.Tests.Beatmaps.IO
[Test]
public void TestReadFile()
{
using (var osz = File.OpenRead(Resource.GetPath("241526 Soleily - Renatus.osz")))
using (var osz = Resource.OpenResource("241526 Soleily - Renatus.osz"))
{
var reader = new OszArchiveReader(osz);
using (var stream = new StreamReader(

View File

@ -6,10 +6,10 @@ namespace osu.Game.Tests.Resources
{
public static class Resource
{
public static string GetPath(string path)
public static Stream OpenResource(string name)
{
var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
return Path.Combine(assemblyDir, "Resources", path);
return Assembly.GetExecutingAssembly().GetManifestResourceStream(
$@"osu.Game.Tests.Resources.{name}");
}
}
}

View File

@ -34,9 +34,6 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="Resources\241526 Soleily - Renatus.osz">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu.Game\osu.Game.csproj">
@ -48,10 +45,16 @@
<Folder Include="Resources\" />
<Folder Include="Beatmaps\" />
<Folder Include="Beatmaps\IO\" />
<Folder Include="Beatmaps\Formats\" />
</ItemGroup>
<ItemGroup>
<Compile Include="Beatmaps\IO\OszArchiveReaderTest.cs" />
<Compile Include="Resources\Resource.cs" />
<Compile Include="Beatmaps\Formats\OsuLegacyDecoderTest.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\241526 Soleily - Renatus.osz" />
<EmbeddedResource Include="Resources\Soleily - Renatus %28Gamu%29 [Insane].osu" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>