public void Test() { using var node = new ofRootNode(); node.RenderElement(this); Assert.That(OneRendered, Is.True); Assert.That(TwoRendered, Is.False); OneRendered = false; DoAlt = true; node.RenderElement(this); Assert.That(OneRendered, Is.False); Assert.That(TwoRendered, Is.True); TwoRendered = false; DoAlt = false; node.RenderElement(this); Assert.That(OneRendered, Is.True); Assert.That(TwoRendered, Is.False); }
public void Test() { using var node = new ofRootNode(); State = 0; node.RenderElement(this); Assert.That(Rendered, Is.EqualTo(0)); State = 1; node.RenderElement(this); Assert.That(Rendered, Is.EqualTo(1)); State = 0; node.RenderElement(this); Assert.That(Rendered, Is.EqualTo(1)); State = 2; node.RenderElement(this); Assert.That(Rendered, Is.EqualTo(2)); }
public void Test() { var node = new ofRootNode(); Assert.That(Effect, Is.EqualTo(0)); Assert.That(Cleanup, Is.EqualTo(0)); node.RenderElement(this); Assert.That(Effect, Is.EqualTo(1)); Assert.That(Cleanup, Is.EqualTo(0)); node.RenderElement(this); Assert.That(Effect, Is.EqualTo(2)); Assert.That(Cleanup, Is.EqualTo(1)); node.RenderElement(this); Assert.That(Effect, Is.EqualTo(3)); Assert.That(Cleanup, Is.EqualTo(2)); node.Dispose(); Assert.That(Effect, Is.EqualTo(3)); Assert.That(Cleanup, Is.EqualTo(3)); }
public void PartlyAmbiguousCtor() { var node = new ofRootNode(); var context = new PartlyAmbiguousCtorElement.Context(); // "my value" is unambiguously a string node.RenderElement(new ofContext <PartlyAmbiguousCtorElement.Context>(value: context) { new ofYamlComponent(key: 1, document: @" render: PartlyAmbiguousCtorElement: value: my value") }); Assert.That(context.TheType, Is.EqualTo(PartlyAmbiguousCtorElement.Type.String)); // "765" can be parsed as string OR integer, so it is ambiguous Assert.That(() => node.RenderElement(new ofContext <PartlyAmbiguousCtorElement.Context>(value: context) { new ofYamlComponent(key: 2, document: @" render: PartlyAmbiguousCtorElement: value: 765") }), Throws.InstanceOf <YamlComponentException>()); }
public void MismatchingBind() { var node = new ofRootNode(); node.RenderElement(new ElementTypeA()); Assert.That(node.RenderElement(new ElementTypeB()), Is.EqualTo(RenderResult.Mismatch)); }
public void Complex() { var node = new ofRootNode(); Assert.That(MountCounting.Mount, Is.EqualTo(0)); Assert.That(MountCounting.Unmount, Is.EqualTo(0)); node.RenderElement(new[] { new MountCounting("first"), new MountCounting("second"), new MountCounting("third") }); Assert.That(MountCounting.Mount, Is.EqualTo(3)); Assert.That(MountCounting.Unmount, Is.EqualTo(0)); node.RenderElement(new[] { new MountCounting("first"), new MountCounting("third") }); Assert.That(MountCounting.Mount, Is.EqualTo(3)); Assert.That(MountCounting.Unmount, Is.EqualTo(1)); node.RenderElement(new[] { new MountCounting("third"), new MountCounting("first") }); Assert.That(MountCounting.Mount, Is.EqualTo(3)); Assert.That(MountCounting.Unmount, Is.EqualTo(1)); node.RenderElement(new[] { new MountCounting("third"), new MountCounting("second"), new MountCounting("first") }); Assert.That(MountCounting.Mount, Is.EqualTo(4)); Assert.That(MountCounting.Unmount, Is.EqualTo(1)); node.RenderElement(new[] { new MountCounting("first") }); Assert.That(MountCounting.Mount, Is.EqualTo(4)); Assert.That(MountCounting.Unmount, Is.EqualTo(3)); node.Dispose(); Assert.That(MountCounting.Mount, Is.EqualTo(4)); Assert.That(MountCounting.Unmount, Is.EqualTo(4)); }
public void Test() { var node = new ofRootNode(); node.RenderElement(this); Alt = true; Assert.That(() => node.RenderElement(this), Throws.InstanceOf <InvalidCastException>()); }
public void Test() { using var node = new ofRootNode(); node.RenderElement(this); Assert.That(Renders, Is.EqualTo(11)); node.RenderElement(this); Assert.That(Renders, Is.EqualTo(12)); }
public void SkipIfSameProps() { var node = new ofRootNode { AlwaysInvalid = false }; // we don't want optimization Assert.That(SkipIfSamePropsElement.Rendered, Is.EqualTo(0)); node.RenderElement(new SkipIfSamePropsElement("test")); Assert.That(SkipIfSamePropsElement.Rendered, Is.EqualTo(1)); node.RenderElement(new SkipIfSamePropsElement("test")); Assert.That(SkipIfSamePropsElement.Rendered, Is.EqualTo(1)); }
public void BadLowercaseName() { var node = new ofRootNode(); Assert.That(() => node.RenderElement(new ofYamlComponent(@" render: fragment:")), Throws.InstanceOf <YamlComponentException>()); // fragment should be titlecased }
public void NoRender() { using var node = new ofRootNode(); node.RenderElement(new ofYamlComponent("")); node.Diagnostics.EnsureRendered(typeof(ofYamlComponent)); }
public void Test() { Assert.That(CurrentCount, Is.EqualTo(0)); Assert.That(CurrentString, Is.Null); using var node = new ofRootNode(); node.RenderElement(this); Assert.That(CurrentCount, Is.EqualTo(1)); Assert.That(CurrentString, Is.EqualTo("1")); node.RenderElement(this); Assert.That(CurrentCount, Is.EqualTo(2)); Assert.That(CurrentString, Is.EqualTo("2")); }
public void EmptyRenderMapping() { using var node = new ofRootNode(); node.RenderElement(new ofYamlComponent("render: {}")); node.Diagnostics.EnsureRendered(typeof(ofYamlComponent)); }
public void Test() { using var node = new ofRootNode(); node.RenderElement(this); Assert.That(Rendered, Is.True); }
public void Test() { using var node = new ofRootNode(); Assert.That(Nested1Rendered, Is.EqualTo(0)); Assert.That(Nested2Rendered, Is.EqualTo(0)); node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(1)); Assert.That(Nested2Rendered, Is.EqualTo(1)); node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(1)); Assert.That(Nested2Rendered, Is.EqualTo(1)); }
public void PrivateCtor() { var node = new ofRootNode(); Assert.That(() => node.RenderElement(new ofYamlComponent(@" render: PrivateCtorElement:")), Throws.InstanceOf <YamlComponentException>()); }
public void AbstractElement() { var node = new ofRootNode(); Assert.That(() => node.RenderElement(new ofYamlComponent(@" render: Element:")), Throws.InstanceOf <YamlComponentException>()); // ofElement is abstract }
public void MultiCtor() { var node = new ofRootNode(); var context = new MultiCtorElement.Context(); node.RenderElement(new ofContext <MultiCtorElement.Context>(value: context) { new ofYamlComponent(key: 1, document: @" render: MultiCtorElement: value1: 1") }); // exact match - 1 param Assert.That(context.Params, Is.EqualTo(1)); node.RenderElement(new ofContext <MultiCtorElement.Context>(value: context) { new ofYamlComponent(key: 2, document: @" render: MultiCtorElement: value1: 1 value2: 2") }); // closest match - 2 param with 1 optional (due to param 2 excess) Assert.That(context.Params, Is.EqualTo(3)); node.RenderElement(new ofContext <MultiCtorElement.Context>(value: context) { new ofYamlComponent(key: 3, document: @" render: MultiCtorElement: value1: 1 value2: 2 value3: 3 value4: 4") }); // closest match - 4 param with 1 optional (due to param 4 excess) Assert.That(context.Params, Is.EqualTo(5)); }
public void EmptyRenderListValues() { using var node = new ofRootNode(); node.RenderElement(new ofYamlComponent(@" render: -")); node.Diagnostics.EnsureRendered(typeof(ofYamlComponent)); }
public void Test() { using var node = new ofRootNode(); node.RenderElement(this); Assert.That(ParentRenders, Is.EqualTo(1)); Assert.That(NestedRenders1, Is.EqualTo(11)); Assert.That(NestedRenders2, Is.EqualTo(1)); }
public void IgnoreNullChild() { using var node = new ofRootNode(); node.RenderElement(new[] { new ofFragment(), null, new ofFragment() }); }
public void Test() { var node = new ofRootNode(); node.RenderElement(this); Assert.That(() => node.Diagnostics.EnsureRendered( typeof(RenderedList), typeof(ofFragment), typeof(Nested2)), Throws.InstanceOf <ArgumentException>()); }
public void FlattenedLists() { using var node = new ofRootNode(); node.RenderElement(new ofYamlComponent(@" render: - - - - - - Fragment: - Fragment:")); node.Diagnostics.EnsureRendered(typeof(ofYamlComponent), typeof(ofFragment), typeof(ofFragment), typeof(ofFragment)); }
public void StringArrayProp() { using var node = new ofRootNode(); node.RenderElement(new ofYamlComponent(@" render: StringArrayPropElement: values: - value 1 - value 2 -")); }
public void EmptyFragment() { using var node = new ofRootNode(); node.RenderElement(new ofYamlComponent(@" render: Fragment:")); node.Diagnostics.EnsureRendered( typeof(ofYamlComponent), typeof(ofFragment)); }
public void RenderIfDifferentProps() { var node = new ofRootNode { AlwaysInvalid = false }; // we don't want optimization node.RenderElement(new RenderIfDifferentPropsElement("test1")); Assert.That(RenderIfDifferentPropsElement.RenderCount, Is.EqualTo(1)); node.RenderElement(new RenderIfDifferentPropsElement("test2")); Assert.That(RenderIfDifferentPropsElement.RenderCount, Is.EqualTo(2)); node.RenderElement(new RenderIfDifferentPropsElement("test2")); Assert.That(RenderIfDifferentPropsElement.RenderCount, Is.EqualTo(2)); node.RenderElement(new RenderIfDifferentPropsElement("test2")); Assert.That(RenderIfDifferentPropsElement.RenderCount, Is.EqualTo(2)); node.RenderElement(new RenderIfDifferentPropsElement("test1")); Assert.That(RenderIfDifferentPropsElement.RenderCount, Is.EqualTo(3)); node.RenderElement(new RenderIfDifferentPropsElement("test1")); Assert.That(RenderIfDifferentPropsElement.RenderCount, Is.EqualTo(3)); }
public void Test() { using var node = new ofRootNode(); node.RenderElement(this); node.Diagnostics.EnsureRendered( typeof(RenderedList), typeof(ofFragment), typeof(Nested1), typeof(Nested1.Nested3), typeof(Nested2)); }
public void Test() { using var node = new ofRootNode(); node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(1)); Assert.That(Nested2Rendered, Is.EqualTo(1)); node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(1)); Assert.That(Nested2Rendered, Is.EqualTo(2)); node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(1)); Assert.That(Nested2Rendered, Is.EqualTo(3)); node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(1)); Assert.That(Nested2Rendered, Is.EqualTo(4)); RemoveNested2 = true; node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(2)); Assert.That(Nested2Rendered, Is.EqualTo(4)); node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(2)); Assert.That(Nested2Rendered, Is.EqualTo(4)); RemoveNested2 = false; node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(3)); Assert.That(Nested2Rendered, Is.EqualTo(5)); node.RenderElement(this); Assert.That(Nested1Rendered, Is.EqualTo(3)); Assert.That(Nested2Rendered, Is.EqualTo(6)); }
public void Test() { var node = new ofRootNode(); Assert.That(Disposed, Is.False); node.RenderElement(this); Assert.That(Disposed, Is.False); node.Dispose(); Assert.That(Disposed, Is.True); }
public void StringJaggedArrayProp() { using var node = new ofRootNode(); node.RenderElement(new ofYamlComponent(@" render: StringJaggedArrayPropElement: values: - - value 1 1 - value 1 2 - - value 2 1 - value 2 2 - value 2 3 -")); }