示例#1
0
    public void CommandContainer_UnbindLifeTime_AreEqual()
    {
        // Arrange
        var container        = new DiContainer();
        var commandContainer = new CommandContainer(container);
        var expected         = commandContainer.Bind <CommandTest>();

        expected.InLocal()
        .InParallel()
        .To <CommandTest>();

        // Act
        commandContainer.Unbind(LifeTime.Global);
        var actual = commandContainer.Bind <CommandTest>();

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

        // Act
        var commandContainer = new CommandContainer(container);
        var actual           = commandContainer.Bind <CommandTest>();

        //Assert
        Assert.IsNotNull(actual);
    }
示例#3
0
    public void CommandContainer_Bind()
    {
        // Arrange
        var container        = new DiContainer();
        var commandContainer = new CommandContainer(container);
        var key = typeof(CommandTest);

        // Act
        var actual = commandContainer.Bind(key);

        //Assert
        Assert.IsNotNull(actual);
    }
示例#4
0
    public void CommandContainer_UnbindGeneric_ReturnTrue()
    {
        // Arrange
        var container        = new DiContainer();
        var commandContainer = new CommandContainer(container);

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

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

        //Assert
        Assert.IsTrue(actual);
    }
示例#5
0
    public void CommandContainer_Bind_Exception()
    {
        // Arrange
        var actual           = false;
        var container        = new DiContainer();
        var commandContainer = new CommandContainer(container);

        // Act
        try
        {
            var unused = commandContainer.Bind(null);
        }
        catch (ArgumentNullException)
        {
            actual = true;
        }

        //Assert
        Assert.IsTrue(actual);
    }
    public void CommandContainer_ReactToAndData()
    {
        // Arrange
        var expected         = new Test();
        var container        = new DiContainer();
        var commandContainer = new CommandContainer(container);

        CommandTest.Callback = () => { };

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

        var actual = CommandTest.DataTest;

        //Assert
        Assert.AreEqual(expected, actual);
    }
示例#7
0
    public void CommandContainer_ReactToGeneric()
    {
        // Arrange
        var actual           = 0;
        var container        = new DiContainer();
        var commandContainer = new CommandContainer(container);

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

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

        // Act
        commandContainer.ReactTo <CommandTest>();

        //Assert
        Assert.AreEqual(2, actual);
    }
示例#8
0
    public void CommandContainer_ReactToAndData()
    {
        // Arrange
        var expected         = new Test();
        var container        = new DiContainer();
        var commandContainer = new CommandContainer(container);
        var key = typeof(CommandTest);

        CommandTest.Callback = () => { };

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

        // Act
        commandContainer.ReactTo(key, expected);
        var actual = CommandTest.DataTest;

        //Assert
        Assert.AreEqual(expected, actual);
    }