Use Razor component in StandaloneApp sample
This commit is contained in:
parent
7e40427ffe
commit
604aa14518
|
|
@ -0,0 +1 @@
|
||||||
|
Hello, world!
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
<h1>Hello, world!</h1>
|
|
||||||
Hello from the Razor component.
|
|
||||||
|
|
@ -2,8 +2,6 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// 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.Browser.Rendering;
|
||||||
using Microsoft.Blazor.Components;
|
|
||||||
using Microsoft.Blazor.RenderTree;
|
|
||||||
|
|
||||||
namespace StandaloneApp
|
namespace StandaloneApp
|
||||||
{
|
{
|
||||||
|
|
@ -12,15 +10,7 @@ namespace StandaloneApp
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
new BrowserRenderer()
|
new BrowserRenderer()
|
||||||
.AddComponent("app", new PlaceholderComponent());
|
.AddComponent("app", new Home());
|
||||||
}
|
|
||||||
|
|
||||||
private class PlaceholderComponent : IComponent
|
|
||||||
{
|
|
||||||
public void BuildRenderTree(RenderTreeBuilder builder)
|
|
||||||
{
|
|
||||||
builder.AddText("Hello from the placeholder component.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,11 @@ namespace Microsoft.Blazor.Build.Core.RazorCompilation
|
||||||
? baseNamespace
|
? baseNamespace
|
||||||
: $"{baseNamespace}.{itemNamespace}";
|
: $"{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 engine = new BlazorRazorEngine();
|
||||||
|
|
||||||
var sourceDoc = RazorSourceDocument.ReadFrom(inputFileContents, inputFilePath);
|
var sourceDoc = RazorSourceDocument.ReadFrom(inputFileContents, inputFilePath);
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
using Microsoft.Blazor.E2ETest.Infrastructure;
|
using Microsoft.Blazor.E2ETest.Infrastructure;
|
||||||
using Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures;
|
using Microsoft.Blazor.E2ETest.Infrastructure.ServerFixtures;
|
||||||
|
using OpenQA.Selenium;
|
||||||
|
using OpenQA.Selenium.Support.UI;
|
||||||
|
using System;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.Blazor.E2ETest.Tests
|
namespace Microsoft.Blazor.E2ETest.Tests
|
||||||
|
|
@ -13,13 +16,27 @@ namespace Microsoft.Blazor.E2ETest.Tests
|
||||||
public StandaloneAppTest(BrowserFixture browserFixture, DevHostServerFixture<StandaloneApp.Program> serverFixture)
|
public StandaloneAppTest(BrowserFixture browserFixture, DevHostServerFixture<StandaloneApp.Program> serverFixture)
|
||||||
: base(browserFixture, serverFixture)
|
: base(browserFixture, serverFixture)
|
||||||
{
|
{
|
||||||
|
Navigate("/", noReload: true);
|
||||||
|
WaitUntilLoaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void HasTitle()
|
public void HasTitle()
|
||||||
{
|
{
|
||||||
Navigate("/");
|
|
||||||
Assert.Equal("Blazor standalone", Browser.Title);
|
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...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue