diff --git a/MLEM.sln b/MLEM.sln index a28f679..49e9478 100644 --- a/MLEM.sln +++ b/MLEM.sln @@ -20,8 +20,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MLEM.Templates", "MLEM.Temp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demos.Android", "Demos.Android\Demos.Android.csproj", "{410C0262-131C-4D0E-910D-D01B4F7143E0}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{B89824FA-CD6D-430D-8952-CDDDB71EC942}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -68,9 +66,5 @@ Global {410C0262-131C-4D0E-910D-D01B4F7143E0}.Debug|Any CPU.Build.0 = Debug|Any CPU {410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.ActiveCfg = Release|Any CPU {410C0262-131C-4D0E-910D-D01B4F7143E0}.Release|Any CPU.Build.0 = Release|Any CPU - {B89824FA-CD6D-430D-8952-CDDDB71EC942}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B89824FA-CD6D-430D-8952-CDDDB71EC942}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B89824FA-CD6D-430D-8952-CDDDB71EC942}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B89824FA-CD6D-430D-8952-CDDDB71EC942}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Tests/CameraTests.cs b/Tests/CameraTests.cs index 455e528..e8583db 100644 --- a/Tests/CameraTests.cs +++ b/Tests/CameraTests.cs @@ -1,4 +1,5 @@ using System.Numerics; +using Microsoft.Xna.Framework.Graphics; using MLEM.Cameras; using NUnit.Framework; using Tests.Stub; @@ -9,7 +10,7 @@ namespace Tests { [Test] public void TestConversions([Range(-4, 4, 4F)] float x, [Range(-4, 4, 4F)] float y) { - var camera = new Camera(new StubGraphics()); + var camera = new Camera(new StubGame().GraphicsDevice); var pos = new Vector2(x, y); var cam = camera.ToCameraPos(pos); var ret = camera.ToWorldPos(cam); diff --git a/Tests/FormattingTests.cs b/Tests/FormattingTests.cs index 8983b2d..b2f8106 100644 --- a/Tests/FormattingTests.cs +++ b/Tests/FormattingTests.cs @@ -24,7 +24,7 @@ namespace Tests { [Test] public void TestFormatting() { var formatter = new TextFormatter(); - formatter.AddImage("Test", new TextureRegion(new Texture2D(new StubGraphics(), 1, 1), 0, 8, 24, 24)); + formatter.AddImage("Test", new TextureRegion(new Texture2D(new StubGame().GraphicsDevice, 1, 1), 0, 8, 24, 24)); const string strg = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book."; var ret = formatter.Tokenize(new StubFont(), strg); Assert.AreEqual(ret.Tokens.Length, 13); diff --git a/Tests/Stub/StubContent.cs b/Tests/Stub/StubContent.cs index bab3541..61e2957 100644 --- a/Tests/Stub/StubContent.cs +++ b/Tests/Stub/StubContent.cs @@ -8,7 +8,7 @@ namespace Tests.Stub { private readonly Dictionary assets; - public StubContent(Dictionary assets) : base(new StubServices()) { + public StubContent(StubGame game, Dictionary assets) : base(game.Services) { this.RootDirectory = Path.Combine(TestContext.CurrentContext.TestDirectory, "Content"); this.assets = assets; } diff --git a/Tests/Stub/StubGame.cs b/Tests/Stub/StubGame.cs new file mode 100644 index 0000000..07b39d9 --- /dev/null +++ b/Tests/Stub/StubGame.cs @@ -0,0 +1,12 @@ +using Microsoft.Xna.Framework; + +namespace Tests.Stub { + public class StubGame : Game { + + public StubGame() { + new GraphicsDeviceManager(this); + this.RunOneFrame(); + } + + } +} \ No newline at end of file diff --git a/Tests/Stub/StubGraphics.cs b/Tests/Stub/StubGraphics.cs deleted file mode 100644 index f7ea579..0000000 --- a/Tests/Stub/StubGraphics.cs +++ /dev/null @@ -1,10 +0,0 @@ -using Microsoft.Xna.Framework.Graphics; - -namespace Tests.Stub { - public class StubGraphics : GraphicsDevice { - - public StubGraphics() : - base(GraphicsAdapter.DefaultAdapter, GraphicsProfile.Reach, new PresentationParameters()) { - } - } -} \ No newline at end of file diff --git a/Tests/Stub/StubServices.cs b/Tests/Stub/StubServices.cs deleted file mode 100644 index 9f5f0ee..0000000 --- a/Tests/Stub/StubServices.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace Tests.Stub { - public class StubServices : IServiceProvider { - - public object GetService(Type serviceType) { - return null; - } - - } -} \ No newline at end of file diff --git a/Tests/TestDataTextureAtlas.cs b/Tests/TestDataTextureAtlas.cs index c6f631e..ca0c06d 100644 --- a/Tests/TestDataTextureAtlas.cs +++ b/Tests/TestDataTextureAtlas.cs @@ -12,8 +12,9 @@ namespace Tests { [Test] public void Test() { - var content = new StubContent(new Dictionary { - {"Texture", new Texture2D(new StubGraphics(), 1, 1)} + var game = new StubGame(); + var content = new StubContent(game, new Dictionary { + {"Texture", new Texture2D(game.GraphicsDevice, 1, 1)} }); var atlas = content.LoadTextureAtlas("Texture"); Assert.AreEqual(atlas.Regions.Count(), 5); diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 2efdf65..91535f7 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -1,11 +1,11 @@ - netcoreapp3.1 + netcoreapp3.0 - +