Test Framework

For now there is only UnitTest support. There is an abstract TarjectUnitTestFixture class that creates a temporary Container to run UnitTests.

Sample uses:

public class SignalControllerTest : TarjectUnitTestFixture
{
    protected override void Setup()
    {
        Container.Bind<SignalController>();
    }

    [Test]
    public void Subscribe()
    {
        SignalController signalController = Container.Resolve<SignalController>();
        signalController.Subscribe<TestSignal>(Action);

        void Action(TestSignal _) { }

        Assert.IsTrue(signalController.Exists<TestSignal>(Action));
    }

    [Test]
    public void Unsubscribe()
    {
        SignalController signalController = Container.Resolve<SignalController>();
        signalController.Subscribe<TestSignal>(Action);
        signalController.Unsubscribe<TestSignal>(Action);

        void Action(TestSignal _) { }

        Assert.IsFalse(signalController.Exists<TestSignal>(Action));
    }

    private readonly struct TestSignal
    {
    }

Last updated