public void FinalDicUpdate() { IObjectPluginConfig finalDic = GetFinalDic(this, SharedDicTestContext.Plugins[0]); _dic.Add(this, SharedDicTestContext.Plugins[0], "key2", "value2"); finalDic["key2"] = "NewValue2"; Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned); Assert.That(_lastConfigChangedEventArgs.Key == "key2"); Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this)); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); })); Assert.That(_lastConfigChangedEventArgs.Obj == this); Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Update); Assert.That((string)_lastConfigChangedEventArgs.Value == "NewValue2"); _lastConfigChangedEventArgs = null; finalDic.GetOrSet("key2", "NewNewValue2"); Assert.IsNull(_lastConfigChangedEventArgs); Assert.Throws <ArgumentNullException>(() => finalDic.GetOrSet <bool>("key2", true, null)); finalDic.GetOrSet <bool>("key2", true, (o) => { return(true); }); Assert.IsNotNull(_lastConfigChangedEventArgs); Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned); Assert.That(_lastConfigChangedEventArgs.Key == "key2"); Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this)); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); })); Assert.That(_lastConfigChangedEventArgs.Obj == this); Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Update); Assert.That((bool)_lastConfigChangedEventArgs.Value == true); }
public void FinalDicAdd() { IObjectPluginConfig finalDic = GetFinalDic(this, SharedDicTestContext.Plugins[0]); finalDic.Add("key1", "value1"); Assert.IsNotNull(_lastConfigChangedEventArgs); Assert.IsNotNull(_lastSender); Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned); Assert.That(_lastConfigChangedEventArgs.Key == "key1"); Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this)); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); })); Assert.That(_lastConfigChangedEventArgs.Obj == this); Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Add); Assert.That((string)_lastConfigChangedEventArgs.Value == "value1"); finalDic["key2"] = "value2"; Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned); Assert.That(_lastConfigChangedEventArgs.Key == "key2"); Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this)); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); })); Assert.That(_lastConfigChangedEventArgs.Obj == this); Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Add); Assert.That((string)_lastConfigChangedEventArgs.Value == "value2"); finalDic.GetOrSet("key3", "value3"); Assert.That(!_lastConfigChangedEventArgs.IsAllConcerned); Assert.That(_lastConfigChangedEventArgs.Key == "key3"); Assert.That(_lastConfigChangedEventArgs.MultiObj.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiObj.Contains(this)); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Count == 1); Assert.That(_lastConfigChangedEventArgs.MultiPluginId.Any((p) => { return(p == SharedDicTestContext.Plugins[0]); })); Assert.That(_lastConfigChangedEventArgs.Obj == this); Assert.That(_lastConfigChangedEventArgs.Status == ChangeStatus.Add); Assert.That((string)_lastConfigChangedEventArgs.Value == "value3"); }