public void TestRegisterGenericFunction() { var messenger = new PluginMessenger(); messenger.Register("Target", "Name", x => 2 + 2); Assert.True(messenger.SendMessage <int>("Target", "Name") == 4); }
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); }
public void TestRegisterAction() { var messenger = new PluginMessenger(); bool value = false; messenger.Register("Target", "Name", x => value = true); messenger.SendMessage("Target", "Name"); Assert.True(value); }
[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); }
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); }