Add E2E test showing we can pass properties to child components and auto re-render them on change

This commit is contained in:
Steve Sanderson 2018-01-29 10:52:12 +00:00
parent 5981002a40
commit 4f496f649a
3 changed files with 32 additions and 0 deletions

View File

@ -113,6 +113,22 @@ namespace Microsoft.AspNetCore.Blazor.E2ETest.Tests
childComponentWrapper.FindElement(By.TagName("p")).Text);
}
[Fact]
public void ChildComponentsRerenderWhenPropertiesChanged()
{
var appElement = MountTestComponent<CounterComponentUsingChild>();
Assert.Equal(
"Current count: 0",
appElement.FindElement(By.TagName("p")).Text);
appElement.FindElement(By.TagName("button")).Click();
Assert.Equal(
"Current count: 1",
appElement.FindElement(By.TagName("p")).Text);
}
private IWebElement MountTestComponent<TComponent>() where TComponent: IComponent
{
var componentTypeName = typeof(TComponent).FullName;

View File

@ -0,0 +1,12 @@
<h1>Counter</h1>
<p>Current count: <c:MessageComponent Message="@currentCount.ToString()" /></p>
<button @onclick(IncrementCount)>Click me</button>
@functions {
int currentCount = 0;
void IncrementCount()
{
currentCount++;
}
}

View File

@ -0,0 +1,4 @@
<span style="color: red">@Message</span>
@functions {
public string Message { get; set; }
}