public void AddOrUpdateTest_AddFactory(string name, object value) { var flag = false; var set = new DistributedPropertySet(); set.MapChanged += (sender, args) => { Assert.Equal(DistributedCollectionChange.ItemInserted, args.DistributedCollectionChange); flag = true; }; Assert.Equal(value, set.AddOrUpdate(name, n => value, null)); Assert.True(flag); }
public void AddOrUpdateTest_UpdateFactory(string name, object addValue, object updateValue) { var flag = false; var set = new DistributedPropertySet(); set.MapChanged += (sender, args) => { if (args.DistributedCollectionChange == DistributedCollectionChange.ItemChanged) { flag = true; } }; Assert.True(set.TryAdd(name, addValue)); Assert.Equal(updateValue, set.AddOrUpdate(name, n => addValue, (n, v) => updateValue)); Assert.True(flag); }