public void ConstructorSetsProject()
        {
            var project = new Project();
            var context = new IntegrationContext(project);

            Assert.AreSame(project, context.Item);
        }
 public void WaitWillContinueIfNotLocked()
 {
     var project = new Project();
     var context = new IntegrationContext(project);
     var released = context.Wait(TimeSpan.FromMilliseconds(5));
     Assert.IsTrue(released);
 }
Example #3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="context">Integration context.</param>
 protected FeatureCoordinator(IntegrationContext context)
 {
     Configuration          = context.Configuration;
     _featureAggregator     = new FeatureReportGenerator(Configuration.ReportWritersConfiguration().ToArray());
     RunnerRepository       = new FeatureRunnerRepository(context);
     ValueFormattingService = context.ValueFormattingService;
 }
Example #4
0
        /// <summary>
        /// Asks the host if an integration can start.
        /// </summary>
        /// <returns>
        /// <c>true</c> if the integration can start; <c>false</c> otherwise.
        /// </returns>
        private bool AskHost()
        {
            var integrate = this.Host == null;

            if (!integrate && (this.currentContext == null))
            {
                this.currentContext = new IntegrationContext(this);
                logger.Debug("Asking host if '{0}' can integrate", this.Name);
                this.Host.AskToIntegrate(this.currentContext);
                if (this.currentContext.IsLocked)
                {
                    this.currentContext.Released += OnContextReleased;
                }
                else
                {
                    integrate = !this.currentContext.WasCancelled;
                    if (!integrate)
                    {
                        this.currentContext = null;
                    }
                }
            }

            return(integrate);
        }
        public void WaitWillContinueIfNotLocked()
        {
            var project  = new Project();
            var context  = new IntegrationContext(project);
            var released = context.Wait(TimeSpan.FromMilliseconds(5));

            Assert.IsTrue(released);
        }
Example #6
0
 public void AskToIntegrateFailsIfUnableToLock()
 {
     var project = new ProjectStub();
     var queue = new TestQueue();
     var context = new IntegrationContext(project);
     queue.Lock();
     Assert.Throws<Exception>(() => queue.AskToIntegrate(context));
 }
        public void AskToIntegrateDoesNothingWithNoHost()
        {
            var project = new Project();
            var context = new IntegrationContext(project);

            project.AskToIntegrate(context);
            Assert.IsTrue(context.Wait(TimeSpan.FromMilliseconds(1)));
        }
 public FeatureRunner(Type featureType, IntegrationContext integrationContext)
 {
     _featureType        = featureType;
     _integrationContext = integrationContext;
     _exceptionProcessor = new ExceptionProcessor(_integrationContext);
     _featureResult      = new FeatureResult(_integrationContext.MetadataProvider.GetFeatureInfo(featureType));
     integrationContext.FeatureProgressNotifier.NotifyFeatureStart(_featureResult.Info);
 }
Example #9
0
 public ScenarioBuilder(object fixture, IntegrationContext integrationContext, ExceptionProcessor exceptionProcessor, Action <IScenarioResult> onScenarioFinished)
 {
     _context = new RunnableScenarioContext(
         integrationContext,
         exceptionProcessor,
         onScenarioFinished,
         integrationContext.ScenarioProgressNotifierProvider.Invoke(fixture),
         ProvideSteps);
 }
Example #10
0
        public void AskToIntegrateFailsIfUnableToLock()
        {
            var project = new ProjectStub();
            var queue   = new TestQueue();
            var context = new IntegrationContext(project);

            queue.Lock();
            Assert.Throws <Exception>(() => queue.AskToIntegrate(context));
        }
Example #11
0
 public void CompletingAnIntegrationFailsIfUnableToLock()
 {
     var project = new ProjectStub();
     var queue = new TestQueue();
     var context = new IntegrationContext(project);
     queue.AskToIntegrate(context);
     queue.Lock();
     Assert.Throws<Exception>(context.Complete);
 }
 public void WaitWillTimeoutIfNotReleased()
 {
     var project = new Project();
     var context = new IntegrationContext(project);
     context.Lock();
     var released = context.Wait(TimeSpan.FromMilliseconds(5));
     Assert.IsFalse(released);
     Assert.IsFalse(context.WasCancelled);
 }
 public void CompletedIsFiredOnComplete()
 {
     var project = new Project();
     var context = new IntegrationContext(project);
     var wasFired = false;
     context.Completed += (o, e) => wasFired = true;
     context.Complete();
     Assert.IsTrue(wasFired);
 }
Example #14
0
        /// <summary>
        /// Called when an integration has completed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OnIntegrationCompleted(object sender, EventArgs e)
        {
            var context = sender as IntegrationContext;

            if ((this.currentContext != null) && !this.currentContext.IsCompleted)
            {
                logger.Debug("Telling host integration has completed in '{0}'", this.Name);
                this.currentContext.Complete();
                this.currentContext = null;
            }

            IntegrationContext nextRequest = null;
            var locked = false;

            try
            {
                locked = this.interleave.TryEnterWriteLock(TimeSpan.FromSeconds(1));
                if (locked)
                {
                    logger.Debug("Removing '{0}' from '{1}'", context.Item.Name, this.Name);
                    context.Completed -= OnIntegrationCompleted;
                    this.activeRequests.Remove(context);

                    if ((this.pendingRequests.Count > 0) && this.AskHost())
                    {
                        nextRequest = this.pendingRequests[0];
                        this.pendingRequests.Remove(nextRequest);
                        logger.Info("Activating '{0}' in '{1}'", nextRequest.Item.Name, this.Name);
                        this.activeRequests.Add(nextRequest);
                        nextRequest.Completed += OnIntegrationCompleted;
                    }
                }
                else
                {
                    var message = "Unable to update queue '" +
                                  this.Name +
                                  "' - unable to acquire lock";
                    logger.Error(message);
                    // TODO: Replace with custom exception
                    throw new Exception(message);
                }
            }
            finally
            {
                if (locked)
                {
                    this.interleave.ExitWriteLock();
                }
            }

            // Release the next request
            if (nextRequest != null)
            {
                nextRequest.Release();
            }
        }
Example #15
0
        public void CompletingAnIntegrationFailsIfUnableToLock()
        {
            var project = new ProjectStub();
            var queue   = new TestQueue();
            var context = new IntegrationContext(project);

            queue.AskToIntegrate(context);
            queue.Lock();
            Assert.Throws <Exception>(context.Complete);
        }
        public void CompletedIsFiredOnComplete()
        {
            var project  = new Project();
            var context  = new IntegrationContext(project);
            var wasFired = false;

            context.Completed += (o, e) => wasFired = true;
            context.Complete();
            Assert.IsTrue(wasFired);
        }
Example #17
0
 public void CompletingAnIntegrationRemovesItFromActiveRequests()
 {
     var project = new ProjectStub();
     var queue = new Queue();
     var context = new IntegrationContext(project);
     queue.AskToIntegrate(context);
     context.Complete();
     Assert.AreEqual(0, queue.GetActiveRequests().Count());
     Assert.AreEqual(0, queue.GetPendingRequests().Count());
 }
Example #18
0
        /// <summary>
        /// Called when the current context has been released.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OnContextReleased(object sender, EventArgs e)
        {
            var integrate = !this.currentContext.WasCancelled;
            var locked    = false;
            IntegrationContext nextRequest = null;

            try
            {
                locked = this.interleave.TryEnterWriteLock(TimeSpan.FromSeconds(1));
                if (locked)
                {
                    if (this.pendingRequests.Count > 0)
                    {
                        nextRequest = this.pendingRequests[0];
                        this.pendingRequests.Remove(nextRequest);
                        if (integrate)
                        {
                            logger.Info("Activating '{0}' in '{1}'", nextRequest.Item.Name, this.Name);
                            this.activeRequests.Add(nextRequest);
                            nextRequest.Completed += OnIntegrationCompleted;
                        }
                    }
                }
                else
                {
                    var message = "Unable to update queue '" +
                                  this.Name +
                                  "' - unable to acquire lock";
                    logger.Error(message);
                    // TODO: Replace with custom exception
                    throw new Exception(message);
                }
            }
            finally
            {
                if (locked)
                {
                    this.interleave.ExitWriteLock();
                }
            }

            // Release or cancel the next request
            if (nextRequest != null)
            {
                if (integrate)
                {
                    nextRequest.Release();
                }
                else
                {
                    logger.Info("Cancelling '{0}' in '{1}'", nextRequest.Item.Name, this.Name);
                    nextRequest.Cancel();
                }
            }
        }
Example #19
0
        public void CompletingAnIntegrationRemovesItFromActiveRequests()
        {
            var project = new ProjectStub();
            var queue   = new Queue();
            var context = new IntegrationContext(project);

            queue.AskToIntegrate(context);
            context.Complete();
            Assert.AreEqual(0, queue.GetActiveRequests().Count());
            Assert.AreEqual(0, queue.GetPendingRequests().Count());
        }
        public void WaitWillTimeoutIfNotReleased()
        {
            var project = new Project();
            var context = new IntegrationContext(project);

            context.Lock();
            var released = context.Wait(TimeSpan.FromMilliseconds(5));

            Assert.IsFalse(released);
            Assert.IsFalse(context.WasCancelled);
        }
Example #21
0
        public FeatureRunner(Type featureType, IntegrationContext integrationContext)
        {
            _featureType        = featureType;
            _integrationContext = integrationContext;
            _featureResult      = new FeatureResult(_integrationContext.MetadataProvider.GetFeatureInfo(featureType));

            _scenarioExecutor = new ScenarioExecutor(new ExtendableExecutor(integrationContext.ExecutionExtensions));
            _scenarioExecutor.ScenarioExecuted += _featureResult.AddScenario;

            integrationContext.FeatureProgressNotifier.NotifyFeatureStart(_featureResult.Info);
        }
Example #22
0
 public RunnableScenarioContext(IntegrationContext integrationContext,
                                ExceptionProcessor exceptionProcessor,
                                Action <IScenarioResult> onScenarioFinished,
                                IScenarioProgressNotifier progressNotifier,
                                ProvideStepsFunc stepsProvider)
 {
     IntegrationContext = integrationContext;
     ExceptionProcessor = exceptionProcessor;
     OnScenarioFinished = onScenarioFinished;
     ProgressNotifier   = progressNotifier;
     StepsProvider      = stepsProvider;
 }
Example #23
0
 public void AskToIntegrateWillTriggerProjectIfFirst()
 {
     var project = new ProjectStub();
     var queue = new Queue();
     var context = new IntegrationContext(project);
     queue.AskToIntegrate(context);
     var canIntegrate = context.Wait(TimeSpan.FromSeconds(5));
     Assert.IsTrue(canIntegrate);
     var active = queue.GetActiveRequests();
     Assert.AreEqual(1, active.Count());
     Assert.AreEqual(0, queue.GetPendingRequests().Count());
     Assert.AreSame(active.First(), context);
 }
 public void WaitWillContinueWhenReleased()
 {
     var project = new Project();
     var context = new IntegrationContext(project);
     var releaseThread = new Thread(o =>
         {
             Thread.Sleep(TimeSpan.FromSeconds(1));
             context.Release();
         });
     releaseThread.Start();
     context.Lock();
     var released = context.Wait(TimeSpan.FromSeconds(5));
     Assert.IsTrue(released);
 }
 public void CancelWillReleaseALock()
 {
     var project = new Project();
     var context = new IntegrationContext(project);
     var releaseThread = new Thread(o =>
         {
             Thread.Sleep(TimeSpan.FromSeconds(1));
             context.Cancel();
         });
     releaseThread.Start();
     context.Lock();
     var released = context.Wait(TimeSpan.FromSeconds(5));
     Assert.IsFalse(released);
     Assert.IsTrue(context.WasCancelled);
 }
        public void WaitWillContinueWhenReleased()
        {
            var project       = new Project();
            var context       = new IntegrationContext(project);
            var releaseThread = new Thread(o =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
                context.Release();
            });

            releaseThread.Start();
            context.Lock();
            var released = context.Wait(TimeSpan.FromSeconds(5));

            Assert.IsTrue(released);
        }
        public void AskToIntegrateAsksHostToContinue()
        {
            var context   = new IntegrationContext(null);
            var wasCalled = false;
            var hostMock  = new Mock <ServerItem>(MockBehavior.Strict);

            hostMock.Setup(h => h.AskToIntegrate(context)).Callback(() => wasCalled = true);
            var project = new Project
            {
                Host = hostMock.Object
            };

            project.AskToIntegrate(context);
            Assert.IsTrue(context.Wait(TimeSpan.FromMilliseconds(1)));
            Assert.IsTrue(wasCalled);
        }
Example #28
0
 public void AskToIntegrateWillQueueSubsequentItems()
 {
     var queue = new Queue();
     var project1 = new ProjectStub();
     var project2 = new ProjectStub();
     var context1 = new IntegrationContext(project1);
     var context2 = new IntegrationContext(project2);
     queue.AskToIntegrate(context1);
     queue.AskToIntegrate(context2);
     var active = queue.GetActiveRequests();
     var pending = queue.GetPendingRequests();
     Assert.AreEqual(1, active.Count());
     Assert.AreEqual(1, pending.Count());
     Assert.AreSame(active.First(), context1);
     Assert.AreSame(pending.First(), context2);
 }
Example #29
0
        public void AskToIntegrateWillTriggerProjectIfFirst()
        {
            var project = new ProjectStub();
            var queue   = new Queue();
            var context = new IntegrationContext(project);

            queue.AskToIntegrate(context);
            var canIntegrate = context.Wait(TimeSpan.FromSeconds(5));

            Assert.IsTrue(canIntegrate);
            var active = queue.GetActiveRequests();

            Assert.AreEqual(1, active.Count());
            Assert.AreEqual(0, queue.GetPendingRequests().Count());
            Assert.AreSame(active.First(), context);
        }
        public void CancelWillReleaseALock()
        {
            var project       = new Project();
            var context       = new IntegrationContext(project);
            var releaseThread = new Thread(o =>
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
                context.Cancel();
            });

            releaseThread.Start();
            context.Lock();
            var released = context.Wait(TimeSpan.FromSeconds(5));

            Assert.IsFalse(released);
            Assert.IsTrue(context.WasCancelled);
        }
Example #31
0
        public void CompletingReleasingSubsequentItems()
        {
            var queue    = new Queue();
            var project1 = new ProjectStub();
            var project2 = new ProjectStub();
            var context1 = new IntegrationContext(project1);
            var context2 = new IntegrationContext(project2);

            queue.AskToIntegrate(context1);
            queue.AskToIntegrate(context2);
            context1.Complete();
            var active = queue.GetActiveRequests();

            Assert.AreEqual(1, active.Count());
            Assert.AreEqual(0, queue.GetPendingRequests().Count());
            Assert.AreSame(context2, active.First());
        }
Example #32
0
        public void AskToIntegrateWillQueueSubsequentItems()
        {
            var queue    = new Queue();
            var project1 = new ProjectStub();
            var project2 = new ProjectStub();
            var context1 = new IntegrationContext(project1);
            var context2 = new IntegrationContext(project2);

            queue.AskToIntegrate(context1);
            queue.AskToIntegrate(context2);
            var active  = queue.GetActiveRequests();
            var pending = queue.GetPendingRequests();

            Assert.AreEqual(1, active.Count());
            Assert.AreEqual(1, pending.Count());
            Assert.AreSame(active.First(), context1);
            Assert.AreSame(pending.First(), context2);
        }
Example #33
0
        /// <summary>
        /// Asks if an item can integrate.
        /// </summary>
        /// <param name="context">The context to use.</param>
        public override void AskToIntegrate(IntegrationContext context)
        {
            var locked = false;

            try
            {
                logger.Debug("Adding integration request for '{0}' to '{1}'", context.Item.Name, this.Name);
                locked = this.interleave.TryEnterWriteLock(TimeSpan.FromSeconds(1));
                if (locked)
                {
                    if ((this.activeRequests.Count < this.AllowedActive.GetValueOrDefault(1)) &&
                        this.AskHost())
                    {
                        logger.Info("Activating '{0}' in '{1}'", context.Item.Name, this.Name);
                        this.activeRequests.Add(context);
                        context.Completed += OnIntegrationCompleted;
                    }
                    else
                    {
                        logger.Info("Adding '{0}' to pending in '{1}'", context.Item.Name, this.Name);
                        this.pendingRequests.Add(context);
                        context.Lock();
                    }
                }
                else
                {
                    var message = "Unable to add new request to '" +
                                  this.Name +
                                  "' - unable to acquire lock";
                    logger.Error(message);
                    // TODO: Replace with custom exception
                    throw new Exception(message);
                }
            }
            finally
            {
                if (locked)
                {
                    this.interleave.ExitWriteLock();
                }
            }
        }
Example #34
0
 public static string EnsureDataTableQualify(DataTable dt, string schemapath, Hashtable param)
 {
     if (param == null)
     {
         param = new Hashtable();
     }
     try
     {
         IntegrationContext context = new IntegrationContext(param);
         context.Schema = ValidationUtils.GetDataSchemaFromFile(schemapath);
         if (context.Schema == null)
         {
             return(string.Format("无法解析出[{0}]的schema", schemapath));
         }
         DataTableStorage.GetDataFromSourceDataTable(dt, context);
         return(context.Message);
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
 public static ExtendedScenarioRunner <TContext> Create(IFeatureFixtureRunner runner, IntegrationContext context)
 {
     return(new ExtendedScenarioRunner <TContext>(runner, context));
 }
Example #36
0
 public MockBddRunner(IntegrationContext ctx, IScenarioRunner scenarioRunner)
 {
     _ctx            = ctx;
     _scenarioRunner = scenarioRunner;
 }
Example #37
0
 /// <summary>
 /// Asks if an item can integrate.
 /// </summary>
 /// <param name="context">The context to use.</param>
 public override void AskToIntegrate(IntegrationContext context)
 {
     throw new NotImplementedException();
 }
Example #38
0
 public ExceptionProcessor(IntegrationContext integrationContext)
 {
     _exceptionToStatusMapper = integrationContext.ExceptionToStatusMapper;
     _exceptionFormatter      = integrationContext.Configuration.ExceptionHandlingConfiguration().ExceptionDetailsFormatter;
 }
 public void AskToIntegrateDoesNothingWithNoHost()
 {
     var project = new Project();
     var context = new IntegrationContext(project);
     project.AskToIntegrate(context);
     Assert.IsTrue(context.Wait(TimeSpan.FromMilliseconds(1)));
 }
Example #40
0
        public void HandlesQueueOfQueues()
        {
            var integrations = new List<string>();
            var contexts = new List<IntegrationContext>();
            var projects = new Project[6];
            for (var loop = 0; loop < projects.Length; loop++)
            {
                var project = new Project("Project" + loop);
                projects[loop] = project;
            }

            var queue1 = new Queue("Queue1", projects[0], projects[1]);
            var queue2 = new Queue("Queue2", projects[2], projects[3]);
            var queue3 = new Queue("Queue3", projects[4], projects[5]);
            var queue4 = new Queue("Queue4", queue1, queue2, queue3)
                             {
                                 AllowedActive = 2
                             };

            // Trying to simulate async code here - need to fire the completion events in the
            // order they are released
            var completed = new List<IntegrationContext>();
            foreach (var project in projects)
            {
                var context = new IntegrationContext(project);
                contexts.Add(context);
                project.Host.AskToIntegrate(context);
                if (context.IsLocked)
                {
                    context.Released += (o, e) =>
                                            {
                                                var subContext = o as IntegrationContext;
                                                completed.Add(subContext);
                                                integrations.Add(subContext.Item.Name);
                                            };
                }
                else
                {
                    completed.Add(context);
                    integrations.Add(project.Name);
                }
            }

            // completed will be modified at the same time we are iterating through it so can't
            // use foreach here
            for (var loop = 0; loop < completed.Count; loop++)
            {
                completed[loop].Complete();
            }

            // These should both be empty at the end of the process
            Assert.AreEqual(0, queue4.GetActiveRequests().Count());
            Assert.AreEqual(0, queue4.GetPendingRequests().Count());

            // Check that there is the correct order
            var expected = new[]
                               {
                                   "Project0",
                                   "Project2",
                                   "Project4",
                                   "Project1",
                                   "Project3",
                                   "Project5"
                               };
            CollectionAssert.AreEqual(expected, integrations);
        }
Example #41
0
        /// <summary>
        /// Called when an integration has completed.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void OnIntegrationCompleted(object sender, EventArgs e)
        {
            var context = sender as IntegrationContext;
            if ((this.currentContext != null) && !this.currentContext.IsCompleted)
            {
                logger.Debug("Telling host integration has completed in '{0}'", this.Name);
                this.currentContext.Complete();
                this.currentContext = null;
            }

            IntegrationContext nextRequest = null;
            var locked = false;
            try
            {
                locked = this.interleave.TryEnterWriteLock(TimeSpan.FromSeconds(1));
                if (locked)
                {
                    logger.Debug("Removing '{0}' from '{1}'", context.Item.Name, this.Name);
                    context.Completed -= OnIntegrationCompleted;
                    this.activeRequests.Remove(context);

                    if ((this.pendingRequests.Count > 0) && this.AskHost())
                    {
                        nextRequest = this.pendingRequests[0];
                        this.pendingRequests.Remove(nextRequest);
                        logger.Info("Activating '{0}' in '{1}'", nextRequest.Item.Name, this.Name);
                        this.activeRequests.Add(nextRequest);
                        nextRequest.Completed += OnIntegrationCompleted;
                    }
                }
                else
                {
                    var message = "Unable to update queue '" +
                        this.Name +
                        "' - unable to acquire lock";
                    logger.Error(message);
                    // TODO: Replace with custom exception
                    throw new Exception(message);
                }
            }
            finally
            {
                if (locked)
                {
                    this.interleave.ExitWriteLock();
                }
            }

            // Release the next request
            if (nextRequest != null)
            {
                nextRequest.Release();
            }
        }
Example #42
0
 /// <summary>
 /// Asks if an item can integrate.
 /// </summary>
 /// <param name="context">The context to use.</param>
 public override void AskToIntegrate(IntegrationContext context)
 {
     var locked = false;
     try
     {
         logger.Debug("Adding integration request for '{0}' to '{1}'", context.Item.Name, this.Name);
         locked = this.interleave.TryEnterWriteLock(TimeSpan.FromSeconds(1));
         if (locked)
         {
             if ((this.activeRequests.Count < this.AllowedActive.GetValueOrDefault(1)) &&
                 this.AskHost())
             {
                 logger.Info("Activating '{0}' in '{1}'", context.Item.Name, this.Name);
                 this.activeRequests.Add(context);
                 context.Completed += OnIntegrationCompleted;
             }
             else
             {
                 logger.Info("Adding '{0}' to pending in '{1}'", context.Item.Name, this.Name);
                 this.pendingRequests.Add(context);
                 context.Lock();
             }
         }
         else
         {
             var message = "Unable to add new request to '" +
                 this.Name +
                 "' - unable to acquire lock";
             logger.Error(message);
             // TODO: Replace with custom exception
             throw new Exception(message);
         }
     }
     finally
     {
         if (locked)
         {
             this.interleave.ExitWriteLock();
         }
     }
 }
 public TRunner Enrich(IFeatureFixtureRunner _, IntegrationContext ctx)
 {
     return(_runnerFactory(_contextualRunner, ctx));
 }
Example #44
0
 public void CompletingReleasingSubsequentItems()
 {
     var queue = new Queue();
     var project1 = new ProjectStub();
     var project2 = new ProjectStub();
     var context1 = new IntegrationContext(project1);
     var context2 = new IntegrationContext(project2);
     queue.AskToIntegrate(context1);
     queue.AskToIntegrate(context2);
     context1.Complete();
     var active = queue.GetActiveRequests();
     Assert.AreEqual(1, active.Count());
     Assert.AreEqual(0, queue.GetPendingRequests().Count());
     Assert.AreSame(context2, active.First());
 }
 /// <summary>
 /// Asks if an item can integrate.
 /// </summary>
 /// <param name="context">The context to use.</param>
 public override void AskToIntegrate(IntegrationContext context)
 {
     throw new NotImplementedException();
 }
 public override void AskToIntegrate(IntegrationContext context)
 {
 }
 public ExtendedScenarioRunner(IFeatureFixtureRunner runner, IntegrationContext context)
 {
     _runner  = runner;
     _context = context;
 }
Example #48
0
        /// <summary>
        /// Asks the host if an integration can start.
        /// </summary>
        /// <returns>
        /// <c>true</c> if the integration can start; <c>false</c> otherwise.
        /// </returns>
        private bool AskHost()
        {
            var integrate = this.Host == null;
            if (!integrate && (this.currentContext == null))
            {
                this.currentContext = new IntegrationContext(this);
                logger.Debug("Asking host if '{0}' can integrate", this.Name);
                this.Host.AskToIntegrate(this.currentContext);
                if (this.currentContext.IsLocked)
                {
                    this.currentContext.Released += OnContextReleased;
                }
                else
                {
                    integrate = !this.currentContext.WasCancelled;
                    if (!integrate)
                    {
                        this.currentContext = null;
                    }
                }
            }

            return integrate;
        }
 public void AskToIntegrateAsksHostToContinue()
 {
     var context = new IntegrationContext(null);
     var wasCalled = false;
     var hostMock = new Mock<ServerItem>(MockBehavior.Strict);
     hostMock.Setup(h => h.AskToIntegrate(context)).Callback(() => wasCalled = true);
     var project = new Project
                       {
                           Host = hostMock.Object
                       };
     project.AskToIntegrate(context);
     Assert.IsTrue(context.Wait(TimeSpan.FromMilliseconds(1)));
     Assert.IsTrue(wasCalled);
 }
 public void ConstructorSetsProject()
 {
     var project = new Project();
     var context = new IntegrationContext(project);
     Assert.AreSame(project, context.Item);
 }