1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-11-25 22:18:34 +01:00

code cleanup

This commit is contained in:
Ell 2022-10-27 10:22:25 +02:00
parent 8745a3237e
commit 791c66b098
15 changed files with 799 additions and 801 deletions

View file

@ -13,9 +13,6 @@ namespace MLEM.Data {
/// A dynamic enum uses <see cref="BigInteger"/> as its underlying type, allowing for an arbitrary number of enum values to be created, even when a <see cref="FlagsAttribute"/>-like structure is used that would only allow for up to 64 values in a regular enum. /// A dynamic enum uses <see cref="BigInteger"/> as its underlying type, allowing for an arbitrary number of enum values to be created, even when a <see cref="FlagsAttribute"/>-like structure is used that would only allow for up to 64 values in a regular enum.
/// All enum operations including <see cref="And{T}"/>, <see cref="Or{T}"/>, <see cref="Xor{T}"/> and <see cref="Neg{T}"/> are supported and can be implemented in derived classes using operator overloads. /// All enum operations including <see cref="And{T}"/>, <see cref="Or{T}"/>, <see cref="Xor{T}"/> and <see cref="Neg{T}"/> are supported and can be implemented in derived classes using operator overloads.
/// To create a custom dynamic enum, simply create a class that extends <see cref="DynamicEnum"/>. New values can then be added using <see cref="Add{T}"/>, <see cref="AddValue{T}"/> or <see cref="AddFlag{T}"/>. /// To create a custom dynamic enum, simply create a class that extends <see cref="DynamicEnum"/>. New values can then be added using <see cref="Add{T}"/>, <see cref="AddValue{T}"/> or <see cref="AddFlag{T}"/>.
///
/// This class, and its entire concept, are extremely terrible. If you intend on using this, there's probably at least one better solution available.
/// Though if, for some weird reason, you need a way to have more than 64 distinct flags, this is a pretty good solution.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// To include enum-like operator overloads in a dynamic enum named MyEnum, the following code can be used: /// To include enum-like operator overloads in a dynamic enum named MyEnum, the following code can be used:

View file

@ -11,6 +11,7 @@ using MLEM.Ui.Style;
#if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER #if NETSTANDARD2_0_OR_GREATER || NET6_0_OR_GREATER
using System.Net.Http; using System.Net.Http;
#else #else
using System.Net; using System.Net;
#endif #endif

View file

@ -2,8 +2,9 @@
using MLEM.Cameras; using MLEM.Cameras;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class CameraTests {
public class CameraTests {
private TestGame game; private TestGame game;
@ -26,5 +27,4 @@ namespace Tests {
Assert.AreEqual(pos, ret); Assert.AreEqual(pos, ret);
} }
}
} }

View file

@ -1,8 +1,9 @@
using MLEM.Extensions; using MLEM.Extensions;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class CollectionTests {
public class CollectionTests {
[Test] [Test]
public void TestCombinations() { public void TestCombinations() {
@ -27,5 +28,4 @@ namespace Tests {
Assert.AreEqual(things.IndexCombinations(), indices); Assert.AreEqual(things.IndexCombinations(), indices);
} }
}
} }

View file

@ -9,8 +9,9 @@ using Newtonsoft.Json;
using NUnit.Framework; using NUnit.Framework;
using Vector2 = Microsoft.Xna.Framework.Vector2; using Vector2 = Microsoft.Xna.Framework.Vector2;
namespace Tests { namespace Tests;
public class DataTests {
public class DataTests {
private readonly TestObject testObject = new() { private readonly TestObject testObject = new() {
Vec = new Vector2(10, 20), Vec = new Vector2(10, 20),
@ -82,5 +83,4 @@ namespace Tests {
} }
}
} }

View file

@ -5,8 +5,9 @@ using MLEM.Data;
using MLEM.Textures; using MLEM.Textures;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class TestDataTextureAtlas {
public class TestDataTextureAtlas {
[Test] [Test]
public void Test([Values(0, 4)] int regionX, [Values(0, 4)] int regionY) { public void Test([Values(0, 4)] int regionX, [Values(0, 4)] int regionY) {
@ -56,5 +57,4 @@ namespace Tests {
Assert.AreEqual("---", data.GetData<string>("DataPoint3")); Assert.AreEqual("---", data.GetData<string>("DataPoint3"));
} }
}
} }

View file

@ -2,8 +2,9 @@ using Microsoft.Xna.Framework;
using MLEM.Misc; using MLEM.Misc;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class DirectionTests {
public class DirectionTests {
[Test] [Test]
public void TestDirections() { public void TestDirections() {
@ -60,5 +61,4 @@ namespace Tests {
return dir; return dir;
} }
}
} }

View file

@ -8,8 +8,9 @@ using MLEM.Formatting.Codes;
using MLEM.Textures; using MLEM.Textures;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class FontTests {
public class FontTests {
private TestGame game; private TestGame game;
private GenericFont font; private GenericFont font;
@ -153,5 +154,4 @@ namespace Tests {
Assert.AreEqual(new Vector2(0, this.font.LineHeight), this.font.MeasureString(GenericFont.Zwsp.ToString())); Assert.AreEqual(new Vector2(0, this.font.LineHeight), this.font.MeasureString(GenericFont.Zwsp.ToString()));
} }
}
} }

View file

@ -2,8 +2,9 @@
using MLEM.Input; using MLEM.Input;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class KeybindTests {
public class KeybindTests {
[Test] [Test]
public void TestCombinationOrder() { public void TestCombinationOrder() {
@ -35,5 +36,4 @@ namespace Tests {
Assert.AreEqual(-1, new Keybind(Keys.A, Keys.LeftAlt).CompareTo(new Keybind(Keys.B, Keys.LeftShift, Keys.RightShift).Add(Keys.B, Keys.RightShift).Add(Keys.C, Keys.RightControl))); Assert.AreEqual(-1, new Keybind(Keys.A, Keys.LeftAlt).CompareTo(new Keybind(Keys.B, Keys.LeftShift, Keys.RightShift).Add(Keys.B, Keys.RightShift).Add(Keys.C, Keys.RightControl)));
} }
}
} }

View file

@ -3,8 +3,9 @@ using MLEM.Extensions;
using MLEM.Misc; using MLEM.Misc;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class NumberTests {
public class NumberTests {
[Test] [Test]
public void TestRounding() { public void TestRounding() {
@ -67,5 +68,4 @@ namespace Tests {
Assert.AreEqual(penetration, 0); Assert.AreEqual(penetration, 0);
} }
}
} }

View file

@ -4,8 +4,9 @@ using Microsoft.Xna.Framework;
using MLEM.Pathfinding; using MLEM.Pathfinding;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class PathfindingTests {
public class PathfindingTests {
[Test] [Test]
public void TestConsistency() { public void TestConsistency() {
@ -123,5 +124,4 @@ namespace Tests {
return new AStar2((_, p2) => costs[p2.Y][p2.X], allowDiagonals, 1, 64, collectAdditionalNeighbors); return new AStar2((_, p2) => costs[p2.Y][p2.X], allowDiagonals, 1, 64, collectAdditionalNeighbors);
} }
}
} }

View file

@ -3,8 +3,9 @@ using MLEM.Data.Content;
using MLEM.Font; using MLEM.Font;
using MLEM.Startup; using MLEM.Startup;
namespace Tests { namespace Tests;
public class TestGame : MlemGame {
public class TestGame : MlemGame {
public RawContentManager RawContent { get; private set; } public RawContentManager RawContent { get; private set; }
@ -22,5 +23,4 @@ namespace Tests {
return game; return game;
} }
}
} }

View file

@ -4,8 +4,9 @@ using MLEM.Data;
using MLEM.Textures; using MLEM.Textures;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class TexturePackerTests {
public class TexturePackerTests {
private Texture2D testTexture; private Texture2D testTexture;
private Texture2D disposedTestTexture; private Texture2D disposedTestTexture;
@ -105,5 +106,4 @@ namespace Tests {
private static void StubResult(TextureRegion region) {} private static void StubResult(TextureRegion region) {}
}
} }

View file

@ -8,8 +8,9 @@ using MLEM.Ui.Elements;
using MLEM.Ui.Style; using MLEM.Ui.Style;
using NUnit.Framework; using NUnit.Framework;
namespace Tests { namespace Tests;
public class UiTests {
public class UiTests {
private TestGame game; private TestGame game;
@ -146,5 +147,4 @@ namespace Tests {
element.ForceUpdateArea(); element.ForceUpdateArea();
} }
}
} }