public void ViewManagersPropertyCache_ViewManager_Set() { var instance = new ViewManagerValueTest(); var setters = ViewManagersPropertyCache.GetNativePropertySettersForViewManagerType(typeof(ViewManagerValueTest)); Assert.AreEqual(3, setters.Count); var props = new ReactStylesDiffMap(new JObject { { "Foo", "v1" }, { "Bar1", "v2" }, { "Bar2", "v3" }, }); AssertEx.Throws<NotSupportedException>(() => setters["Foo"].UpdateShadowNodeProperty(new ShadowNodeValueTest(), props)); AssertEx.Throws<ArgumentNullException>( () => setters["Foo"].UpdateViewManagerProperty(null, null, props), ex => Assert.AreEqual("viewManager", ex.ParamName)); AssertEx.Throws<ArgumentNullException>( () => setters["Foo"].UpdateViewManagerProperty(instance, null, null), ex => Assert.AreEqual("props", ex.ParamName)); setters["Foo"].UpdateViewManagerProperty(instance, null, props); setters["Bar1"].UpdateViewManagerProperty(instance, null, props); setters["Bar2"].UpdateViewManagerProperty(instance, null, props); Assert.AreEqual("v1", instance.FooValue); Assert.AreEqual("v2", instance.BarValues[0]); Assert.AreEqual("v3", instance.BarValues[1]); }
public void ViewManagersPropertyCache_ViewManager_Set() { var instance = new ViewManagerValueTest(); var setters = ViewManagersPropertyCache.GetNativePropertySettersForViewManagerType(typeof(ViewManagerValueTest)); Assert.AreEqual(3, setters.Count); var props = new ReactStylesDiffMap(new JObject { { "Foo", "v1" }, { "Bar1", "v2" }, { "Bar2", "v3" }, }); AssertEx.Throws <NotSupportedException>(() => setters["Foo"].UpdateShadowNodeProperty(new ShadowNodeValueTest(), props)); AssertEx.Throws <ArgumentNullException>( () => setters["Foo"].UpdateViewManagerProperty(null, null, props), ex => Assert.AreEqual("viewManager", ex.ParamName)); AssertEx.Throws <ArgumentNullException>( () => setters["Foo"].UpdateViewManagerProperty(instance, null, null), ex => Assert.AreEqual("props", ex.ParamName)); setters["Foo"].UpdateViewManagerProperty(instance, null, props); setters["Bar1"].UpdateViewManagerProperty(instance, null, props); setters["Bar2"].UpdateViewManagerProperty(instance, null, props); Assert.AreEqual("v1", instance.FooValue); Assert.AreEqual("v2", instance.BarValues[0]); Assert.AreEqual("v3", instance.BarValues[1]); }