public void GetValue_GuardClauses() { // Arrange var valueProvider = new NameValuePairsValueProvider(_backingStore, null); // Act & assert Assert.ThrowsArgumentNull(() => valueProvider.GetValue(null), "key"); }
public void GetValue_ReturnsNullIfKeyNotFound() { // Arrange var valueProvider = new NameValuePairsValueProvider(_backingStore, null); // Act ValueProviderResult vpResult = valueProvider.GetValue("bar"); // Assert Assert.Null(vpResult); }
public void GetValue_SingleValue() { // Arrange var culture = CultureInfo.GetCultureInfo("fr-FR"); var valueProvider = new NameValuePairsValueProvider(_backingStore, culture); // Act ValueProviderResult vpResult = valueProvider.GetValue("bar.baz"); // Assert Assert.NotNull(vpResult); Assert.Equal("someOtherValue", vpResult.RawValue); Assert.Equal("someOtherValue", vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }
public void GetValue_NullValue(string key) { // Arrange var culture = CultureInfo.GetCultureInfo("fr-FR"); var valueProvider = new NameValuePairsValueProvider(_backingStore, culture); // Act ValueProviderResult vpResult = valueProvider.GetValue(key); // Assert Assert.NotNull(vpResult); Assert.Null(vpResult.RawValue); Assert.Null(vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }
static void Main(string[] args) { List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>(); list.Add(new KeyValuePair<string, string>("foobar", "1")); list.Add(new KeyValuePair<string, string>("foobar", "2")); list.Add(new KeyValuePair<string, string>("foobar", "3")); NameValuePairsValueProvider valueProvider = new NameValuePairsValueProvider(list, null); var result = valueProvider.GetValue("foobar"); int[] value1 = (int[])result.ConvertTo(typeof(int[])); int value2 = (int)result.ConvertTo(typeof(int)); Console.WriteLine("{0,-16}{1}", "RawValue", "NewValue"); Console.WriteLine("{0,-16}{1}", result.RawValue.ConvertToString(), value1.ConvertToString()); Console.WriteLine("{0,-16}{1}", result.RawValue.ConvertToString(), value2.ConvertToString()); }
public void GetValue_MultiValue() { // Arrange var culture = CultureInfo.GetCultureInfo("fr-FR"); var valueProvider = new NameValuePairsValueProvider(_backingStore, culture); // Act ValueProviderResult vpResult = valueProvider.GetValue("foo"); // Assert Assert.NotNull(vpResult); Assert.Equal(new List <string>() { "fooValue1", "fooValue2" }, (List <string>)vpResult.RawValue); Assert.Equal("fooValue1,fooValue2", vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }
public void GetValue_NullMultipleValue() { // Arrange var backingStore = new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("key", null), new KeyValuePair <string, string>("key", null), new KeyValuePair <string, string>("key", "value") }; var culture = CultureInfo.GetCultureInfo("fr-FR"); var valueProvider = new NameValuePairsValueProvider(backingStore, culture); // Act ValueProviderResult vpResult = valueProvider.GetValue("key"); // Assert Assert.Equal(new[] { null, null, "value" }, vpResult.RawValue as IEnumerable <string>); Assert.Equal(",,value", vpResult.AttemptedValue); }
public void GetValue_MultiValue() { // Arrange var culture = CultureInfo.GetCultureInfo("fr-FR"); var valueProvider = new NameValuePairsValueProvider(_backingStore, culture); // Act ValueProviderResult vpResult = valueProvider.GetValue("foo"); // Assert Assert.NotNull(vpResult); Assert.Equal(new List<string>() { "fooValue1", "fooValue2" }, (List<string>)vpResult.RawValue); Assert.Equal("fooValue1,fooValue2", vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }
public void GetValue_GuardClauses() { // Arrange var valueProvider = new NameValuePairsValueProvider(_backingStore, null); // Act & assert Assert.ThrowsArgumentNull( () => valueProvider.GetValue(null), "key"); }
public void GetValue_NullMultipleValue() { // Arrange var backingStore = new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("key", null), new KeyValuePair<string, string>("key", null), new KeyValuePair<string, string>("key", "value") }; var culture = CultureInfo.GetCultureInfo("fr-FR"); var valueProvider = new NameValuePairsValueProvider(backingStore, culture); // Act ValueProviderResult vpResult = valueProvider.GetValue("key"); // Assert Assert.Equal(new[] { null, null, "value" }, vpResult.RawValue as IEnumerable<string>); Assert.Equal(",,value", vpResult.AttemptedValue); }
public void GetValue_NullValue(string key) { // Arrange var culture = CultureInfo.GetCultureInfo("fr-FR"); var valueProvider = new NameValuePairsValueProvider(_backingStore, culture); // Act ValueProviderResult vpResult = valueProvider.GetValue(key); // Assert Assert.NotNull(vpResult); Assert.Equal(null, vpResult.RawValue); Assert.Equal(null, vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }