コード例 #1
0
        public void TestRegisterGenericFunction()
        {
            var messenger = new PluginMessenger();

            messenger.Register("Target", "Name", x => 2 + 2);
            Assert.True(messenger.SendMessage <int>("Target", "Name") == 4);
        }
コード例 #2
0
        public void TestRegisterParameterizedFunction(object input, string toString)
        {
            var messenger = new PluginMessenger();

            messenger.Register("Target", "Name", x => input.ToString());
            Assert.True(messenger.SendMessage <string>("Target", "Name", new object[] { input }) == toString);
        }
コード例 #3
0
        public void TestRegisterAction()
        {
            var  messenger = new PluginMessenger();
            bool value     = false;

            messenger.Register("Target", "Name", x => value = true);
            messenger.SendMessage("Target", "Name");
            Assert.True(value);
        }
コード例 #4
0
        [InlineData("", "Name", "", "Name", true)]             // Check that an non-specific target can be targeted by supplying a non-specific target. what.
        public void TestInvalidIdentifierMatches(string registerTarget, string registerName, string sendTarget, string sendName, bool expectedMatch)
        {
            var  messenger = new PluginMessenger();
            bool value     = false;

            messenger.Register(registerTarget, registerName, x => value = true);
            messenger.SendMessage(sendTarget, sendName);
            Assert.True(value == expectedMatch);
        }
コード例 #5
0
        public void TestRegisterParameterizedAction(string target, string name, bool expectedValue)
        {
            var  messenger = new PluginMessenger();
            bool value     = false;

            messenger.Register(target, name, (x) => value = (bool)x[0]);
            messenger.SendMessage(target, name, new object[] { expectedValue });
            Assert.True(value == expectedValue);
        }