private void TestCustomAttribute <T>(T value, Func <IUserBuilder, string, T, IUserBuilderCanMakeAttributePrivate> setter, LdValue.Converter <T> converter) { var user0 = setter(User.Builder(key), "foo", value).Build(); Assert.Equal(value, converter.ToType(user0.Custom["foo"])); Assert.Empty(user0.PrivateAttributeNames); var user1 = setter(User.Builder(key), "bar", value).AsPrivateAttribute().Build(); Assert.Equal(value, converter.ToType(user1.Custom["bar"])); Assert.Equal(new HashSet <string> { "bar" }, user1.PrivateAttributeNames); }
private void TestTypeConversion <T, U>(T fromValue, U toValue, Func <T, LdValue> constructor, LdValue.Converter <U> converter, Func <LdValue, U> getter) { var value = constructor(fromValue); Assert.Equal(toValue, getter(value)); Assert.Equal(toValue, converter.ToType(value)); }
private void TestNonNumericValueAsNumericTypeIsZero <T>(LdValue.Converter <T> converter, Func <LdValue, T> getter, T zero) { var values = new LdValue[] { LdValue.Null, aTrueBoolValue, aStringValue, aNumericLookingStringValue, anArrayValue, anObjectValue }; foreach (var value in values) { Assert.Equal(zero, getter(value)); Assert.Equal(zero, converter.ToType(value)); } }