private async Task ExecuteFixtureTests(ContainerComponent container) { foreach (var(_, fixture) in container.GetComponents <Fixture>()) { container.Render(fixture.ChildContent); var testData = container.GetComponents <FragmentBase>().Select(x => x.Component).ToArray(); _testContextAdapter.ActivateRazorTestContext(testData); InvokeFixtureAction(fixture, fixture.Setup); await InvokeFixtureAction(fixture, fixture.SetupAsync).ConfigureAwait(false); InvokeFixtureAction(fixture, fixture.Test); await InvokeFixtureAction(fixture, fixture.TestAsync).ConfigureAwait(false); foreach (var test in fixture.Tests) { InvokeFixtureAction(fixture, test); } foreach (var test in fixture.TestsAsync) { await InvokeFixtureAction(fixture, test).ConfigureAwait(false); } _testContextAdapter.DisposeActiveTestContext(); } }
public async Task RazorTest() { var container = new ContainerComponent(_renderer.Value); container.Render(BuildRenderTree); await ExecuteFixtureTests(container).ConfigureAwait(false); await ExecuteSnapshotTests(container).ConfigureAwait(false); }
public void RazorTest() { var container = new ContainerComponent(_renderer.Value); container.Render(BuildRenderTree); ExecuteFixtureTests(container); ExecuteSnapshotTests(container); }
/// <summary> /// Creates an instance of the <see cref="RenderedFragmentBase"/> class. /// </summary> public RenderedFragmentBase(ITestContext testContext, RenderFragment renderFragment) { if (testContext is null) { throw new ArgumentNullException(nameof(testContext)); } TestContext = testContext; Container = new ContainerComponent(testContext.Renderer); Container.Render(renderFragment); testContext.Renderer.OnRenderingHasComponentUpdates += ComponentMarkupChanged; }
private void ExecuteSnapshotTests(ContainerComponent container) { foreach (var(_, snapshot) in container.GetComponents <SnapshotTest>()) { container.Render(snapshot.ChildContent); var testData = container.GetComponents <FragmentBase>().Select(x => x.Component).ToArray(); var context = _testContextAdapter.ActivateSnapshotTestContext(testData); snapshot.Setup(); var actual = context.RenderTestInput(); var expected = context.RenderExpectedOutput(); actual.MarkupMatches(expected, snapshot.Description); _testContextAdapter.DisposeActiveTestContext(); } }