Пример #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();
            }
        }
Пример #2
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();
            }
        }