Example #1
0
        protected virtual object RunFixtureSetUp(Fixture fixture, object fixtureInstance)
        {
            if (fixture == null)
            {
                throw new ArgumentNullException("fixture");
            }

            ReportMonitor monitor = new ReportMonitor();

            try
            {
                if (fixture.HasSetUp)
                {
                    monitor.Start();
                    fixture.SetUp(fixtureInstance);
                    monitor.Stop();

                    ReportSetUpAndTearDown setup = new ReportSetUpAndTearDown("TestFixtureSetUp", monitor);
                    if (this.Report != null)
                    {
                        this.Report.TestFixtureSetUp(fixture, setup);
                    }
                    this.OnTestFixtureSetUp(new ReportSetUpAndTearDownEventArgs(setup));
                }

                return(fixtureInstance);
            }
            catch (Exception ex)
            {
                monitor.Stop();
                if (fixture.HasSetUp)
                {
                    ReportSetUpAndTearDown setup = new ReportSetUpAndTearDown("TestFixtureSetUp", monitor, ex);
                    if (this.Report != null)
                    {
                        this.Report.TestFixtureSetUp(fixture, setup);
                    }
                    this.OnTestFixtureSetUp(new ReportSetUpAndTearDownEventArgs(setup));
                }

                // fail all starters
                FixtureSetUpFailedException setUpEx = new FixtureSetUpFailedException(ex);
                FailStarters(fixture, monitor, setUpEx);

                // add error message
                return(null);
            }
        }
Example #2
0
        public async Task Create_DocumentCollection_IfNotExistsAsync_NormalCase()
        {
            var fixture = new Fixture();

            fixture.ExpectedDatabaseId       = "foo";
            fixture.ExpectedUniquePolicyPath = "/name";
            fixture.SetUp();

            var context = new ApplicationDbContext(fixture.Client, fixture.ExpectedDatabaseId, fixture.Logger);
            var policy  = new UniqueKeyPolicy();

            policy.AddUniqueKey(fixture.ExpectedUniquePolicyPath);
            await context.CreateDocumentCollectionIfNotExistsAsync <Package>(policy);


            Assert.Equal("dbs/" + fixture.ExpectedDatabaseId, fixture.ActualDatabaseOriginalPath);
            Assert.Equal(fixture.ExpectedUniquePolicyPath, fixture.ActualUniqueKey[0].Paths[0]);
        }
Example #3
0
        private IEnumerable<IExecutionStep> toExecutionSteps(FixtureLibrary library, Fixture fixture)
        {
            var setup = SilentAction.AsCritical("Fixture", Stage.setup, x =>
            {
                fixture.Context = x;
                fixture.SetUp();
            }, this);
            setup.Subject = Key + ":SetUp";

            yield return setup;

            // Ignore comments!
            foreach (var step in Children.OfType<Step>())
            {
                var grammar = fixture.GrammarFor(step.Key);
                yield return grammar.CreatePlan(step, library);
            }

            var teardown = SilentAction.AsCritical("Fixture", Stage.teardown, x => fixture.TearDown(), this);
            teardown.Subject = Key + ":TearDown";
            yield return teardown;
        }
Example #4
0
        private IEnumerable<IExecutionStep> toExecutionSteps(FixtureLibrary library, Fixture fixture)
        {
            var setup = SilentAction.AsCritical("Fixture", Stage.setup, x =>
            {
                fixture.Context = x;
                fixture.SetUp();
            }, this);
            setup.Subject = Key + ":SetUp";

            yield return setup;

            // Ignore comments!
            foreach (var step in Children.OfType<Step>())
            {
                var grammar = fixture.GrammarFor(step.Key);
                yield return grammar.CreatePlan(step, library);
            }

            var teardown = SilentAction.AsCritical("Fixture", Stage.teardown, x => fixture.TearDown(), this);
            teardown.Subject = Key + ":TearDown";
            yield return teardown;
        }
Example #5
0
        protected virtual object RunFixtureSetUp(Fixture fixture, object fixtureInstance)
        {
            if (fixture == null)
                throw new ArgumentNullException("fixture");

            ReportMonitor monitor = new ReportMonitor();
            try
            {
                if (fixture.HasSetUp)
                {
                    monitor.Start();
                    fixture.SetUp(fixtureInstance);
                    monitor.Stop();

                    ReportSetUpAndTearDown setup = new ReportSetUpAndTearDown("TestFixtureSetUp", monitor);
                    if (this.Report!=null)
                        this.Report.TestFixtureSetUp(fixture, setup);
                    this.OnTestFixtureSetUp(new ReportSetUpAndTearDownEventArgs(setup));
                }

                return fixtureInstance;
            }
            catch (Exception ex)
            {
                monitor.Stop();
                if (fixture.HasSetUp)
                {
                    ReportSetUpAndTearDown setup = new ReportSetUpAndTearDown("TestFixtureSetUp", monitor, ex);
                    if (this.Report != null)
                        this.Report.TestFixtureSetUp(fixture, setup);
                    this.OnTestFixtureSetUp(new ReportSetUpAndTearDownEventArgs(setup));
                }

                // fail all starters
                FixtureSetUpFailedException setUpEx = new FixtureSetUpFailedException(ex);
                FailStarters(fixture, monitor, setUpEx);

                // add error message
                return null;
            }
        }