Example #1
0
 private IDictionary <int, object> CreateMethodFixtures(IXunitTestCase testCase, RunSummary runSummary)
 {
     try {
         _stopwatch.Restart();
         var methodFixtures = MethodFixtureProvider.CreateMethodFixtures(_methodFixtureTypes, _assemblyFixtureMappings);
         _stopwatch.Stop();
         runSummary.Aggregate(new RunSummary {
             Time = (decimal)_stopwatch.Elapsed.TotalSeconds
         });
         return(methodFixtures);
     } catch (Exception exception) {
         _stopwatch.Stop();
         runSummary.Aggregate(RegisterFailedRunSummary(testCase, (decimal)_stopwatch.Elapsed.TotalSeconds, exception));
         return(null);
     }
 }
Example #2
0
        private static async Task AddAssemblyFixtureAsync(IDictionary <Type, object> fixtures, Type fixtureType)
        {
            var fixture = Activator.CreateInstance(fixtureType);

            if (fixture is IAsyncLifetime asyncLifetime)
            {
                await asyncLifetime.InitializeAsync();
            }

            if (typeof(ITestMainThreadFixture).IsAssignableFrom(fixtureType))
            {
                fixtures[typeof(ITestMainThreadFixture)] = fixture;
            }

            fixtures[fixtureType] = fixture;
            var methodFixtureTypes = MethodFixtureProvider.GetFactoryMethods(fixtureType).Select(mi => mi.ReturnType);

            foreach (var type in methodFixtureTypes)
            {
                fixtures[type] = fixture;
            }
        }