public void Switcher_DelegateRegistrationReplace_Success() { var swithcer = new DelegateSwitcher <Func <int> >(); swithcer.Register(1, () => 1); swithcer.Register(1, () => 2); Assert.IsNull(swithcer.Active); Assert.AreEqual(2, swithcer[1]()); }
public void Switcher_DelegateSwitch_Success() { var swithcer = new DelegateSwitcher <Func <int> >(); Assert.IsNull(swithcer.Active); swithcer.Register(1, () => 1); Assert.IsNull(swithcer.Active); swithcer.Switch(1); Assert.IsNotNull(swithcer.Active); Assert.AreEqual(1, swithcer.Active()); }
public ExpressionTypeCache(string root) { if (root == null) { throw new ArgumentNullException(nameof(root)); } _root = root; _types = new List <Type>(); _factory = new DelegateSwitcher <Func <object> >(); _factory.RegisterAndSwitch(nameof(StateDefault), StateDefault); _factory.Register(nameof(StateErrorMultipleTypes), StateErrorMultipleTypes); }