public void ButtonWithTextBlockRender_AllEventsAreCalledInCorrectOrder() { var textBlock = new Props.TextBlock(); var button = new Props.Button { Content = textBlock }; renderer = CreateRenderer(() => button); renderer.Render(NewState.Empty); var textBlockComponent = textBlock.Component; var buttonComponent = button.Component; int index = 0; Assert.That(buttonComponent.WillMountCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(buttonComponent.DidMountCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(buttonComponent.ShouldUpdateCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(buttonComponent.WillReceivePropsCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(textBlockComponent.WillMountCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(textBlockComponent.DidMountCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(textBlockComponent.ShouldUpdateCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(textBlockComponent.WillReceivePropsCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(textBlockComponent.DidUpdateCounter(), Is.EqualTo(new int[] { index++ })); Assert.That(buttonComponent.DidUpdateCounter(), Is.EqualTo(new int[] { index++ })); }
public void WhenTextBlock_CreatesComponents() { var element = new Elements.TextBlock(); var props = new Props.TextBlock(); renderer.UpdateExistingElement(element, props); Assert.That(props.Component, Is.Not.Null); }
public void WhenTextBlock_PreviousElementIsRemoved() { var element = new Elements.TextBlock(); var props = new Props.TextBlock(); renderer.UpdateExistingElement(element, props); renderer.UpdateExistingElement(new Elements.TextBlock(), props); Assert.That(props.Component.Element, Is.Not.SameAs(element)); }
public void WhenTextBlock_UpdatesProperties() { var element = new Elements.TextBlock(); var props = new Props.TextBlock { Text = "test", IsEnabled = true, Focusable = true }; renderer.UpdateExistingElement(element, props); Assert.That(element.Text, Is.EqualTo(props.Text)); Assert.That(element.IsEnabled, Is.True); Assert.That(element.Focusable, Is.True); }
public void WhenContentControl_UpdatesProperties() { var element = new Elements.ContentControl { Content = new Elements.TextBlock() }; var content = new Props.TextBlock { Text = "test", IsEnabled = true, Focusable = true }; var props = new Props.ContentControl { Content = content }; renderer.UpdateExistingElement(element, props); var actual = (Elements.TextBlock)element.Content; Assert.That(actual.Text, Is.EqualTo(content.Text)); Assert.That(actual.IsEnabled, Is.True); Assert.That(actual.Focusable, Is.True); }
public void WhenTextBlockPreviousAndNextIsButton_OneElementInList() { var textBlockProp = new Props.TextBlock(); // makes sure component and element are created textBlockProp.Init(); textBlockProp.Component.WillMount(); var element = (Elements.UIElement)textBlockProp.Component.Element; //var elements = new List<Elements.UIElement> { element }; var actual = renderer.VisitAllCollection(0, new NewState(), previous: new List <ISharpProp> { textBlockProp }, next: new List <ISharpProp> { new Props.Button() }, "sourceProperty", "sourceType"); Assert.That(actual.Length, Is.EqualTo(1)); }
public void WhenContentControl_PreviousElementsAreRemoved() { var element = new Elements.ContentControl { Content = new Elements.TextBlock() }; var content = new Props.TextBlock { Text = "test", IsEnabled = true, Focusable = true }; var props = new Props.ContentControl { Content = content }; renderer.UpdateExistingElement(element, props); renderer.UpdateExistingElement(new Elements.ContentControl { Content = new Elements.TextBlock() }, props); var actual = (Elements.TextBlock)element.Content; Assert.That(props.Component.Element, Is.Not.SameAs(element)); Assert.That(content.Component.Element, Is.Not.SameAs(element.Content)); }