Use Razor component in StandaloneApp sample

This commit is contained in:
Steve Sanderson 2018-01-15 22:57:01 +00:00
parent 7e40427ffe
commit 604aa14518
5 changed files with 25 additions and 14 deletions

View File

@ -0,0 +1 @@
Hello, world!

View File

@ -1,2 +0,0 @@
<h1>Hello, world!</h1>
Hello from the Razor component.

View File

@ -2,8 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.Blazor.Browser.Rendering;
using Microsoft.Blazor.Components;
using Microsoft.Blazor.RenderTree;
namespace StandaloneApp
{
@ -12,15 +10,7 @@ namespace StandaloneApp
public static void Main(string[] args)
{
new BrowserRenderer()
.AddComponent("app", new PlaceholderComponent());
}
private class PlaceholderComponent : IComponent
{
public void BuildRenderTree(RenderTreeBuilder builder)
{
builder.AddText("Hello from the placeholder component.");
}
.AddComponent("app", new Home());
}
}
}

View File

@ -90,6 +90,11 @@ namespace Microsoft.Blazor.Build.Core.RazorCompilation
? baseNamespace
: $"{baseNamespace}.{itemNamespace}";
// TODO: Pass through info about whether this is a design-time build, and if so,
// just emit enough of a stub class that intellisense will show the correct type
// name and any public members. Don't need to actually emit all the RenderTreeBuilder
// invocations.
var engine = new BlazorRazorEngine();
var sourceDoc = RazorSourceDocument.ReadFrom(inputFileContents, inputFilePath);

View File

@ -3,6 +3,9 @@
using Microsoft.Blazor.E2ETest.Infrastructure;
using Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures;
using OpenQA.Selenium;
using OpenQA.Selenium.Support.UI;
using System;
using Xunit;
namespace Microsoft.Blazor.E2ETest.Tests
@ -13,13 +16,27 @@ namespace Microsoft.Blazor.E2ETest.Tests
public StandaloneAppTest(BrowserFixture browserFixture, DevHostServerFixture<StandaloneApp.Program> serverFixture)
: base(browserFixture, serverFixture)
{
Navigate("/", noReload: true);
WaitUntilLoaded();
}
[Fact]
public void HasTitle()
{
Navigate("/");
Assert.Equal("Blazor standalone", Browser.Title);
}
[Fact]
public void HasBodyText()
{
var bodyText = Browser.FindElement(By.TagName("body")).Text;
Assert.Equal("Hello, world!", bodyText);
}
private void WaitUntilLoaded()
{
new WebDriverWait(Browser, TimeSpan.FromSeconds(30)).Until(
driver => driver.FindElement(By.TagName("app")).Text != "Loading...");
}
}
}