This commit is contained in:
2025-03-30 16:06:57 +02:00
parent e62bd2aa6d
commit 623ba3f621
148 changed files with 2773 additions and 1441 deletions

View File

@@ -2,11 +2,11 @@
using RebootKit.Engine.Foundation;
namespace Tests.Runtime.Engine {
internal interface ITestService {
interface ITestService {
int Value();
}
internal class TestServiceA : ITestService {
class TestServiceA : ITestService {
public const int k_ReturnValue = 1;
public int Value() {
@@ -14,7 +14,7 @@ namespace Tests.Runtime.Engine {
}
}
internal class TestServiceB : ITestService {
class TestServiceB : ITestService {
public const int k_ReturnValue = 2;
public int Value() {
@@ -34,11 +34,6 @@ namespace Tests.Runtime.Engine {
Assert.IsTrue(testService.Value() == TestServiceA.k_ReturnValue, "Invalid return value of resolved service");
}
private class TestObject {
[Inject]
public ITestService Service;
}
[Test]
public void Single_Bind_And_Field_Inject() {
DIContext context = new();
@@ -46,20 +41,10 @@ namespace Tests.Runtime.Engine {
TestObject obj = new();
context.Inject(obj);
Assert.IsNotNull(obj.Service, "obj.Service != null");
Assert.IsTrue(obj.Service.Value() == TestServiceB.k_ReturnValue);
}
private class TestObjectMethod {
public ITestService Service;
[Inject]
public void Setup(ITestService service) {
Service = service;
}
}
[Test]
public void Single_Bind_And_Method_Inject() {
@@ -68,9 +53,23 @@ namespace Tests.Runtime.Engine {
TestObjectMethod obj = new();
context.Inject(obj);
Assert.IsNotNull(obj.Service, "obj.Service != null");
Assert.IsTrue(obj.Service.Value() == TestServiceA.k_ReturnValue);
}
class TestObject {
[Inject] public ITestService Service;
}
class TestObjectMethod {
public ITestService Service;
[Inject]
public void Setup(ITestService service) {
Service = service;
}
}
}
}

View File

@@ -0,0 +1,46 @@
using NUnit.Framework;
using RebootKit.Engine.Foundation;
namespace Tests.Runtime.Engine {
public class EitherTests {
[Test]
public void Either_Left_IsCorrect() {
Either<int, string> either = Either<int, string>.FromLeft(1);
Assert.IsTrue(either.IsLeft);
Assert.IsFalse(either.IsRight);
Assert.AreEqual(1, either.Left);
}
[Test]
public void Either_Right_IsCorrect() {
Either<int, string> either = Either<int, string>.FromRight("test");
Assert.IsFalse(either.IsLeft);
Assert.IsTrue(either.IsRight);
Assert.AreEqual("test", either.Right);
}
[Test]
public void Either_Match_Left_IsCorrect() {
const int k_expectedValue = 10;
Either<int, string> either = Either<int, string>.FromLeft(k_expectedValue);
int matchedValue = 0;
either.Match(v => { matchedValue = v; }, _ => { });
Assert.AreEqual(matchedValue, k_expectedValue);
}
[Test]
public void Either_Match_Right_IsCorrect() {
const string k_expectedValue = "reboot_test";
Either<int, string> either = Either<int, string>.FromRight(k_expectedValue);
string matchedValue = "invalid";
either.Match(_ => { }, v => { matchedValue = v; });
Assert.AreEqual(matchedValue, k_expectedValue);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 21990b25866a49168d3a0b1b310aae33
timeCreated: 1742936988

View File

@@ -0,0 +1,26 @@
using NUnit.Framework;
using RebootKit.Engine.Foundation;
namespace Tests.Runtime.Engine {
public class PredicateTests {
[Test]
public void Predicate_And_TwoConditions_IsValid() {
IPredicate predicate = new PredicateAnd(new[] {
new PredicateConsts(true),
new PredicateConsts(true)
});
Assert.IsTrue(predicate.Evaluate());
}
[Test]
public void Predicate_Or_TwoConditions_IsValid() {
IPredicate predicate = new PredicateOr(new[] {
new PredicateConsts(true),
new PredicateConsts(false)
});
Assert.IsTrue(predicate.Evaluate());
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8c1821f7a0fd40d7a6137604082f1501
timeCreated: 1742938325

View File

@@ -1,20 +1,20 @@
{
"name": "RebootKit.Engine.Tests",
"rootNamespace": "",
"references": [
"GUID:284059c7949783646b281a1b815580e6",
"GUID:0acc523941302664db1f4e527237feb3",
"GUID:27619889b8ba8c24980f49ee34dbb44a"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
"name": "RebootKit.Engine.Tests",
"rootNamespace": "",
"references": [
"GUID:284059c7949783646b281a1b815580e6",
"GUID:0acc523941302664db1f4e527237feb3",
"GUID:27619889b8ba8c24980f49ee34dbb44a"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}