public void ViewManagersPropCache_ShadowNode_Set() { var instance = new ShadowNodeValueTest(); var setters = ViewManagersPropCache.GetNativePropSettersForShadowNodeType(typeof(ShadowNodeValueTest)); Assert.AreEqual(3, setters.Count); var props = new JObject { { "Foo", 42 }, { "Qux1", "v2" }, { "Qux2", "v3" }, }; AssertEx.Throws <NotSupportedException>(() => setters["Foo"].UpdateViewManagerProp(new ViewManagerValueTest(), null, props)); AssertEx.Throws <ArgumentNullException>( () => setters["Foo"].UpdateShadowNodeProp(null, props), ex => Assert.AreEqual("shadowNode", ex.ParamName)); AssertEx.Throws <ArgumentNullException>( () => setters["Foo"].UpdateShadowNodeProp(instance, null), ex => Assert.AreEqual("props", ex.ParamName)); setters["Foo"].UpdateShadowNodeProp(instance, props); setters["Qux1"].UpdateShadowNodeProp(instance, props); setters["Qux2"].UpdateShadowNodeProp(instance, props); Assert.AreEqual(42, instance.FooValue); Assert.AreEqual("v2", instance.QuxValues[0]); Assert.AreEqual("v3", instance.QuxValues[1]); }
public void ViewManagersPropCache_ArgumentChecks() { AssertEx.Throws <ArgumentNullException>( () => ViewManagersPropCache.GetNativePropsForView <object>(null, typeof(object)), ex => Assert.AreEqual("viewManagerType", ex.ParamName)); AssertEx.Throws <ArgumentNullException>( () => ViewManagersPropCache.GetNativePropsForView <object>(typeof(object), null), ex => Assert.AreEqual("shadowNodeType", ex.ParamName)); AssertEx.Throws <ArgumentNullException>( () => ViewManagersPropCache.GetNativePropSettersForViewManagerType <object>(null), ex => Assert.AreEqual("type", ex.ParamName)); AssertEx.Throws <ArgumentNullException>( () => ViewManagersPropCache.GetNativePropSettersForShadowNodeType (null), ex => Assert.AreEqual("type", ex.ParamName)); }
public void ViewManagersPropCache_ShadowNode_Empty() { var setters = ViewManagersPropCache.GetNativePropSettersForShadowNodeType(typeof(ReactShadowNode)); Assert.AreEqual(0, setters.Count); }