Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
 internal RenderedComponent(ITestContext testContext, ContainerComponent container, int componentId, TComponent component)
     : base(testContext, container)
 {
     ComponentId       = componentId;
     Instance          = component;
     FirstRenderMarkup = Markup;
 }
Exemplo n.º 3
0
        public async Task RazorTest()
        {
            var container = new ContainerComponent(_renderer.Value);

            container.Render(BuildRenderTree);

            await ExecuteFixtureTests(container).ConfigureAwait(false);
            await ExecuteSnapshotTests(container).ConfigureAwait(false);
        }
Exemplo n.º 4
0
        private async Task 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();
                await snapshot.SetupAsync().ConfigureAwait(false);

                var actual   = context.RenderTestInput();
                var expected = context.RenderExpectedOutput();
                actual.MarkupMatches(expected, snapshot.Description);
                _testContextAdapter.DisposeActiveTestContext();
            }
        }