public void GetOrAddTest_AddFactoryWithArgument(string name, object value) { var flag = false; var set = new DistributedPropertySet(); set.MapChanged += (sender, args) => { if (args.DistributedCollectionChange == DistributedCollectionChange.ItemInserted) { flag = true; } }; Assert.Equal(value, set.GetOrAdd(name, (n, arg) => arg, value)); Assert.Equal(value, set.TryGetValue(name, out var outValue) ? outValue : null); Assert.True(flag); }
public void GetOrAddTest_Get(string name, object value) { var flag = false; var set = new DistributedPropertySet(); set.MapChanged += (sender, args) => { if (args.DistributedCollectionChange == DistributedCollectionChange.ItemInserted) { flag = true; } }; Assert.True(set.TryAdd(name, value)); flag = false; Assert.Equal(value, set.GetOrAdd(name, null)); Assert.False(flag); }