Esempio n. 1
0
        private void ExecuteFixture(int fixtureNumber, int testNumber, Dictionary <string, int> knownspecs, IFixture fixture, List <Spec> futureSpecs)
        {
            try
            {
                try
                {
                    LastException = null;
                    fixture.Execute();
                }
                catch (Exception e)
                {
                    LastException = e;
                }

                var testedSpecs = fixture.AssertSpecs();
                foreach (var testedSpec in testedSpecs)
                {
                    knownspecs[testedSpec.Key] += testedSpec.Value;
                }

                futureSpecs.AddRange(fixture.GetFutureSpecs());
                foreach (var spec in futureSpecs.Where(s => s.ForFixture == fixture.GetType()))
                {
                    try
                    {
                        knownspecs[spec.Name] += spec.Verify();
                    }
                    catch (FalsifiableException ex)
                    {
                        ex.Spec = spec;
                        throw;
                    }
                }
                if (LastException != null)
                {
                    throw new UnexpectedException(LastException);
                }
            }
            catch (FalsifiableException)
            {
                try
                {
                    if (LastException != null)
                    {
                        throw new UnexpectedException(LastException);
                    }
                    throw;
                }
                catch (FalsifiableException failure)
                {
                    disposables.ForEach(d => d.Dispose());
                    if (shrink)
                    {
                        throw new RunReport(testNumber + 1, fixtureNumber + 1, failure, Shrink(executedFixtures, failure));
                    }
                    throw new RunReport(testNumber + 1, fixtureNumber + 1, failure, null);
                }
            }
        }