public void MethodInvoker_StandardInvoke_ReturnsValue() { InstanceFactory.Clear(); var methodInfo = typeof(InstanceFactoryTests).GetMethod(nameof(InstanceFactoryTests.AddNumbers)); var invoker = InstanceFactory.CreateInstanceMethodInvoker(methodInfo); var instance = new InstanceFactoryTests(); var result = invoker(instance, 5, 3); Assert.AreEqual(8, result); // ensure it was cached. Assert.AreEqual(1, InstanceFactory.MethodInvokers.Count); InstanceFactory.Clear(); }
public void PropertySetterInvoker_StandardInvoke_ReturnsValue() { InstanceFactory.Clear(); var invokerSet = InstanceFactory.CreatePropertySetterInvokerCollection(typeof(InstanceFactoryTests)); // ensure the "gettable" only property was skipped Assert.AreEqual(1, invokerSet.Count); invokerSet.TryGetValue(nameof(SettableNumber), out var invoker); Assert.IsNotNull(invoker); var instance = new InstanceFactoryTests(); invoker(instance, 13); Assert.AreEqual(13, instance.SettableNumber); // ensure it was cached. Assert.AreEqual(1, InstanceFactory.PropertyInvokers.Count); InstanceFactory.Clear(); }