コード例 #1
0
    public void SignalCommandContainer_UnbindLifeTime_AreEqual()
    {
        // Arrange
        var container        = new DiContainer();
        var commandContainer = new SignalCommandContainer(container);
        var expected         = commandContainer.Bind <SignalTest>();

        var unused = expected.InGlobal()
                     .InParallel()
                     .To <CommandTest>();

        // Act
        commandContainer.Unbind(LifeTime.Local);
        var actual = commandContainer.Bind <SignalTest>();

        //Assert
        Assert.AreEqual(expected, actual);
    }
コード例 #2
0
    public void SignalCommandContainer_Bind()
    {
        // Arrange
        var container = new DiContainer();

        // Act
        var signalCommandContainer = new SignalCommandContainer(container);
        var actual = signalCommandContainer.Bind <SignalTest>();

        //Assert
        Assert.IsNotNull(actual);
    }
コード例 #3
0
    public void SignalCommandContainer_Unbind_ReturnTrue()
    {
        // Arrange
        var container        = new DiContainer();
        var commandContainer = new SignalCommandContainer(container);

        commandContainer.Bind <SignalTest>()
        .InGlobal()
        .InParallel()
        .To <CommandTest>();

        // Act
        var actual = commandContainer.Unbind <SignalTest>();

        //Assert
        Assert.IsTrue(actual);
    }
コード例 #4
0
    public void SignalCommandContainer_UnbindLifeTime_SignalRelease()
    {
        // Arrange
        var container        = new DiContainer();
        var commandContainer = new SignalCommandContainer(container);
        var signal           = container.GetInstance <SignalTest>();

        var unused = commandContainer.Bind <SignalTest>()
                     .InLocal()
                     .InParallel()
                     .To <CommandTest>();

        // Act
        commandContainer.Unbind(LifeTime.Local);
        var actual = signal.Dispatch();

        //Assert
        Assert.IsFalse(actual);
    }
コード例 #5
0
    public void SignalCommandContainer_ReactTo()
    {
        // Arrange
        var actual           = 0;
        var container        = new DiContainer();
        var commandContainer = new SignalCommandContainer(container);

        CommandTest.Callback = () => actual++;

        // Act
        commandContainer.Bind <SignalTest>()
        .InGlobal()
        .InParallel()
        .To <CommandTest>()
        .To <CommandTest>()
        .Execute();

        //Assert
        Assert.AreEqual(2, actual);
    }
コード例 #6
0
    public void SignalCommandContainer_Bind_Exception()
    {
        // Arrange
        var actual    = false;
        var container = new DiContainer();
        var signalCommandContainer = new SignalCommandContainer(container);

        // Act
        try
        {
            var unused = signalCommandContainer.Bind <SignalFakeTest>();
        }
        catch (InvalidOperationException)
        {
            actual = true;
        }

        //Assert
        Assert.IsNotNull(actual);
    }