mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Properly allow tests to use content files
This commit is contained in:
parent
fe67b70332
commit
3e0fac9a14
4 changed files with 25 additions and 24 deletions
16
Tests/Content/Texture.atlas
Normal file
16
Tests/Content/Texture.atlas
Normal file
|
@ -0,0 +1,16 @@
|
|||
SimpleDeskUp
|
||||
loc 0 0 48 32
|
||||
piv 16 16
|
||||
SimpleDeskRight
|
||||
loc 48 0 48 32
|
||||
piv 80 16
|
||||
|
||||
Plant
|
||||
loc 96 0 16 32
|
||||
|
||||
LongTableUp
|
||||
loc 0 32 64 48
|
||||
piv 16 48
|
||||
LongTableRight
|
||||
loc 64 32 64 48
|
||||
piv 112 48
|
|
@ -1,5 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Tests.Stub {
|
||||
public class StubContent : ContentManager {
|
||||
|
@ -7,6 +9,7 @@ namespace Tests.Stub {
|
|||
private readonly Dictionary<string, object> assets;
|
||||
|
||||
public StubContent(Dictionary<string, object> assets) : base(new StubServices()) {
|
||||
this.RootDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "Content");
|
||||
this.assets = assets;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,30 +12,10 @@ namespace Tests {
|
|||
|
||||
[Test]
|
||||
public void Test() {
|
||||
const string data = @"
|
||||
SimpleDeskUp
|
||||
loc 0 0 48 32
|
||||
piv 16 16
|
||||
SimpleDeskRight
|
||||
loc 48 0 48 32
|
||||
piv 80 16
|
||||
|
||||
Plant
|
||||
loc 96 0 16 32
|
||||
|
||||
LongTableUp
|
||||
loc 0 32 64 48
|
||||
piv 16 48
|
||||
LongTableRight
|
||||
loc 64 32 64 48
|
||||
piv 112 48";
|
||||
using (var file = new FileInfo("texture.atlas").CreateText())
|
||||
file.Write(data);
|
||||
|
||||
var content = new StubContent(new Dictionary<string, object> {
|
||||
{"texture", new Texture2D(new StubGraphics(), 1, 1)}
|
||||
{"Texture", new Texture2D(new StubGraphics(), 1, 1)}
|
||||
});
|
||||
var atlas = content.LoadTextureAtlas("texture");
|
||||
var atlas = content.LoadTextureAtlas("Texture");
|
||||
Assert.AreEqual(atlas.Regions.Count(), 5);
|
||||
|
||||
var table = atlas["LongTableUp"];
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net462</TargetFramework>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -21,7 +21,9 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="texture.atlas" />
|
||||
<Content Include="Content\**">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in a new issue