public void FromValue_can_enumerate_key_value_pairs() { var pp = PropertyProvider.FromArray("a", "c"); Assert.Equal(new [] { KeyValuePair.Create("0", (object)"a"), KeyValuePair.Create("1", (object)"c"), }, ((IEnumerable <KeyValuePair <string, object> >)pp).ToArray()); }
public void GetProperty_will_access_item_by_name() { var pp = new PropertyProviderCollection(); pp["name"] = PropertyProvider.FromArray(0, 1); Assert.Equal(1, pp.GetProperty("1")); Assert.Equal(typeof(int), ((IPropertyProvider)pp).GetPropertyType("1")); }
public void FromArray_can_return_Null_for_empty_array() { var pp = PropertyProvider.FromArray(); Assert.Same(PropertyProvider.Null, pp); pp = PropertyProvider.FromArray(null); Assert.Same(PropertyProvider.Null, pp); }
public void FromArray_uses_property_type_of_array_for_null_items() { var pp = PropertyProvider.FromArray(new A(), new B(), null); // Due to it being null, we use the prevailing type of the array which is A[] // Assert.Equal(typeof(A), pp.GetPropertyType("2")); // Use the specific type of the value Assert.Equal(typeof(A), pp.GetPropertyType("0")); Assert.Equal(typeof(B), pp.GetPropertyType("1")); }
public void Indexer_set_will_replace_item_by_index() { var pp = new PropertyProviderCollection(); var prop1 = PropertyProvider.FromArray(0); var prop2 = PropertyProvider.FromArray(0); pp.AddNew("name", prop1); pp[0] = prop2; Assert.DoesNotContain(prop1, pp); Assert.Same(prop2, pp[0]); }
public void FromValue_can_format_as_strings() { var pp = PropertyProvider.FromArray("a", "c"); Assert.Equal("0=a;1=c", pp.ToString()); }
public void FromArray_allows_property_names_not_an_index() { var pp = PropertyProvider.FromArray("a", "c"); Assert.Null(pp.GetProperty("a")); }
public void FromArray_returns_correct_type() { var pp = PropertyProvider.FromArray("a", "c"); Assert.IsInstanceOf <ArrayPropertyProvider>(pp); }