示例#1
0
        public override void Handle(IIntent <LightingValue> obj)
        {
            LightingValue startValue = obj.GetStateAt(TimeSpan.Zero);
            // This is gross, but it's because when you get a value from an intent, the time
            // is used in an exclusive manner for reasons.  So this is trying to backup
            // the end time without affecting the the resulting value too much.
            LightingValue endValue = obj.GetStateAt(obj.TimeSpan - _oneTick);

            // Why we have to do this? I have no idea, but without it, the gradient rendering gives strange artefacts.
            // (If you want to see what I mean, make a long spin (minutes) across a bunch of elements in a group with
            // a simple pulse down (or up). The ends/starts of the effect flip to the color of the other end briefly,
            // for a single pixel width. I'm guessing it's an issue in the gradient rendering for large shapes where
            // the gradient rectangle is within the same integer range as the rendering rectangle.
            float      offset            = _rect.X * 0.004F;
            RectangleF gradientRectangle = new RectangleF(
                (_rect.X) - offset,
                _rect.Y,
                (_rect.Width) + (2 * offset),
                _rect.Height
                );

            //(float)Math.Floor(_rect.X) - (_rect.X / 300),   _rect.Y,   (float)Math.Ceiling(_rect.Width) + (_rect.Right / 300) + 1.0F,  _rect.Height

            using (LinearGradientBrush brush = new LinearGradientBrush(gradientRectangle, startValue.GetAlphaChannelIntensityAffectedColor(), endValue.GetAlphaChannelIntensityAffectedColor(), LinearGradientMode.Horizontal)) {
                _graphics.FillRectangle(brush, _rect);
            }
        }
示例#2
0
        public ISuiteProvider Load(IIntent assemblyIntent)
        {
            var assembly   = Assembly.LoadFrom(assemblyIntent.Identity.Absolute);
            var provider   = SuiteProvider.Create(assemblyIntent.Identity, assembly.GetName().Name, ignored: false);
            var controller = _suiteControllerFactory.Create(provider);

            var explorationData = _assemblyExplorer.Explore(assembly);

            var lazyBootstraps = explorationData.BootstrapTypes.Select(x => new TypedLazy <ILazyBootstrap>(x)).ToList();
            var suiteTypes     = Filter(assemblyIntent, explorationData.SuiteTypes);

            provider.SuiteProviders = suiteTypes.Select(x => Load(x, explorationData.TypeLoaders, lazyBootstraps, provider.Identity));
            lazyBootstraps
            .Where(x => x.IsValueCreated)
            .Select(x => x.Value)
            .ForEach(
                x =>
                controller.AddSetupCleanup <SetupCommon, CleanupCommon>(
                    x.GetType().Name + ".Setup",
                    x.Setup,
                    x.GetType().Name + ".Cleanup",
                    x.Cleanup));

            return(provider);
        }
示例#3
0
        public ISuiteProvider Load(IIntent assemblyIntent)
        {
            var assembly   = Assembly.LoadFrom(assemblyIntent.Identity.Absolute);
            var provider   = SuiteProvider.Create(assemblyIntent.Identity, assembly.GetName().Name, ignoreReason: null);
            var controller = _suiteControllerFactory.Create(provider);

            var explorationData = _assemblyExplorer.Explore(assembly);

            var suiteProviders = LoadSuiteProviders(
                assemblyIntent,
                explorationData.TestLoaderFactories.ToList(),
                explorationData.PotentialSuiteTypes.ToList(),
                explorationData.AssemblySetupTypes);

            provider.SuiteProviders = suiteProviders;
            explorationData.AssemblySetupTypes.Values
            .Where(x => x.IsValueCreated)
            .Select(x => x.Value)
            .ForEach(
                x => controller.AddSetupCleanup <SetupCommon, CleanupCommon>(
                    x.GetType().Name + ".Setup",
                    x.Setup,
                    x.GetType().Name + ".Cleanup",
                    x.Cleanup));

            return(provider);
        }
        public override void Handle(IIntent<LightingValue> obj)
        {
            LightingValue startValue = obj.GetStateAt(TimeSpan.Zero);
            // This is gross, but it's because when you get a value from an intent, the time
            // is used in an exclusive manner for reasons.  So this is trying to backup
            // the end time without affecting the the resulting value too much.
            LightingValue endValue = obj.GetStateAt(obj.TimeSpan - _oneTick);

            // Why we have to do this? I have no idea, but without it, the gradient rendering gives strange artefacts.
            // (If you want to see what I mean, make a long spin (minutes) across a bunch of channels in a group with
            // a simple pulse down (or up). The ends/starts of the effect flip to the color of the other end briefly,
            // for a single pixel width. I'm guessing it's an issue in the gradient rendering for large shapes where
            // the gradient rectangle is within the same integer range as the rendering rectangle.
            float offset = _rect.X * 0.004F;
            RectangleF gradientRectangle = new RectangleF(
                (_rect.X) - offset,
                _rect.Y,
                (_rect.Width) + (2 * offset),
                _rect.Height
                );
            //(float)Math.Floor(_rect.X) - (_rect.X / 300),   _rect.Y,   (float)Math.Ceiling(_rect.Width) + (_rect.Right / 300) + 1.0F,  _rect.Height

            using (LinearGradientBrush brush = new LinearGradientBrush(gradientRectangle, startValue.GetAlphaChannelIntensityAffectedColor(), endValue.GetAlphaChannelIntensityAffectedColor(), LinearGradientMode.Horizontal)) {
                _graphics.FillRectangle(brush, _rect);
            }
        }
示例#5
0
        public ISuiteProvider Load(IIntent assemblyIntent)
        {
            var assembly = Assembly.LoadFrom(assemblyIntent.Identity.Absolute);
              var provider = SuiteProvider.Create(assemblyIntent.Identity, assembly.GetName().Name, ignored: false);
              var controller = _suiteControllerFactory.Create(provider);

              var explorationData = _assemblyExplorer.Explore(assembly);

              var lazyBootstraps = explorationData.BootstrapTypes.Select(x => new TypedLazy<ILazyBootstrap>(x)).ToList();
              var suiteTypes = Filter(assemblyIntent, explorationData.SuiteTypes);

              provider.SuiteProviders = suiteTypes.Select(x => Load(x, explorationData.TypeLoaders, lazyBootstraps, provider.Identity));
              lazyBootstraps
              .Where(x => x.IsValueCreated)
              .Select(x => x.Value)
              .ForEach(
              x =>
                  controller.AddSetupCleanup<SetupCommon, CleanupCommon>(
                      x.GetType().Name + ".Setup",
                      x.Setup,
                      x.GetType().Name + ".Cleanup",
                      x.Cleanup));

              return provider;
        }
示例#6
0
        /// <summary>
        /// Handles the skill intent as an asynchronous operation.
        /// </summary>
        /// <param name="intent">The intent to handle.</param>
        /// <param name="session">The Alexa session.</param>
        /// <returns>
        /// A <see cref="Task{TResult}"/> representing the asynchronous operation
        /// which returns the <see cref="ResponseBody"/> to return from the skill.
        /// </returns>
        public async Task <SkillResponse> OnIntentAsync(Intent intent, Session session)
        {
            TrackEvent(intent.Name, session, intent);

            IIntent userIntent = IntentFactory.Create(intent);

            return(await userIntent.RespondAsync(intent, session));
        }
 private Task CreateDynamicTask (IIntent intent, string text)
 {
   var parentTask = _taskDictionary[intent.Identity.Parent.NotNull()];
   var dynamicTask = new DynamicTask(parentTask.Id, intent.Identity, text);
   _server.CreateDynamicElement(dynamicTask);
   _taskDictionary.Add(intent.Identity, dynamicTask);
   return dynamicTask;
 }
    private void Started (IIntent intent, string text)
    {
      Task task;
      if (!_taskDictionary.TryGetValue(intent.Identity, out task))
        task = CreateDynamicTask(intent, text);

      _server.TaskStarting(task);
    }
示例#9
0
        /// <summary>
        /// Handles the specified intent.
        /// </summary>
        public void HandleIntent(IIntent intent, OpenTabOptions options)
        {
            // Handle the intent.
            var tabIntent = (IItemDetailsTabIntent)intent;
            var location  = mSubsettingExampleLocations.GeneratePathToItem(tabIntent.Id, tabIntent.Source);

            ItemUrl = location.ToString();
        }
示例#10
0
 public ISuiteResult Run(IIntent assemblyIntent)
 {
     using (SetupTraceListeners())
       {
     var suiteProvider = _assemblyLoader.Load(assemblyIntent);
     return _suiteRunner.Run(assemblyIntent, suiteProvider);
       }
 }
示例#11
0
 public ISuiteResult Run(IIntent assemblyIntent)
 {
     using (SetupTraceListeners())
     {
         var suiteProvider = _assemblyLoader.Load(assemblyIntent);
         return(_suiteRunner.Run(assemblyIntent, suiteProvider));
     }
 }
 public SampleRules(IListener st, INLP nlp, IIntent intent, ExtraStateInformation es)
 {
     // store the dependencies
     this.st     = st;
     this.nlp    = nlp;
     this.intent = intent;
     this.es     = es;
 }
示例#13
0
        public IntentState(IIntent <ResultType> intent, TimeSpan intentRelativeTime)
        {
            if (intent == null)
            {
                throw new ArgumentNullException("intent");
            }

            Intent       = intent;
            RelativeTime = intentRelativeTime;
        }
        public virtual IConversation Create(LuisResult result, IIntent intent)
        {
            var convo = Provider.GetService <IConversation>();

            convo.Result = result;
            convo.Intent = intent;
            convo.Data   = new Dictionary <string, ParameterData>();

            return(convo);
        }
示例#15
0
        /// <summary>
        /// Handles the specified intent.
        /// </summary>
        public void HandleIntent(IIntent intent, OpenTabOptions options)
        {
            // Handle the intent.
            var tabIntent = (ISubsettingTabIntent)intent;

            // Note: This example does not use the Data property, but in general
            // an intent can have any content, and all of that content is
            // available here.
            var intentData = tabIntent.Data;
        }
示例#16
0
        public void Rasterize(IIntent intent, RectangleF rect, Graphics g)
        {
            // As recommended by R#
            if(Math.Abs(rect.Width - 0) < float.Epsilon || Math.Abs(rect.Height - 0) < float.Epsilon) return;

            _rect = rect;
            _graphics = g;

            intent.Dispatch(this);
        }
示例#17
0
        public static EffectIntents RenderNode(IElementNode node, double level, Color color, TimeSpan duration)
        {
            var elementData = new EffectIntents();

            if (node.Element != null && level > 0)
            {
                IIntent intent = IntentBuilder.CreateIntent(color, color, level, level, TimeSpan.FromMilliseconds(duration.TotalMilliseconds));
                elementData.AddIntentForElement(node.Element.Id, intent, TimeSpan.Zero);
            }
            return(elementData);
        }
示例#18
0
 private IEnumerable <Type> Filter(IIntent assemblyIntent, IEnumerable <Type> suiteTypes)
 {
     if (!assemblyIntent.Intents.Any())
     {
         return(suiteTypes);
     }
     else
     {
         return(suiteTypes.Where(x => assemblyIntent.Intents.Any(y => y.Identity.Relative == x.FullName)));
     }
 }
示例#19
0
        public override bool Equals(object obj)
        {
            IIntent intent   = obj as IIntent;
            bool    isEquals = false;

            if (intent != null)
            {
                return(EqualsIntent(intent));
            }

            return(base.Equals(obj));
        }
示例#20
0
		public void Rasterize(IIntent intent, RectangleF rect, Graphics g, TimeSpan startOffset, TimeSpan endTime)
		{
			// As recommended by R#
			if (Math.Abs(rect.Width - 0) < float.Epsilon || Math.Abs(rect.Height - 0) < float.Epsilon) return;

			_rect = rect;
			_graphics = g;
			_startOffset = startOffset;
			_endTime = endTime;

			intent.Dispatch(this);
		}
示例#21
0
 public override void Handle(IIntent<RGBValue> obj)
 {
     if (obj is StaticArrayIntent<RGBValue>) {
         Func<TimeSpan, Color> scg = x => obj.GetStateAt(x).ColorWithAplha;
         Func<TimeSpan, Color> ecg = x => obj.GetStateAt(x - _oneTick).ColorWithAplha;
         DrawStaticArrayIntent(obj.TimeSpan, _rect, scg, ecg);
     } else {
         Color startColor = obj.GetStateAt(TimeSpan.Zero).ColorWithAplha;
         Color endColor = obj.GetStateAt(obj.TimeSpan - _oneTick).ColorWithAplha;
         DrawGradient(startColor, endColor, _rect);
     }
 }
示例#22
0
        /// <summary>
        /// Initializes a new instance of the intent factory
        /// </summary>
        /// <param name="intents">intents injected over DI</param>
        /// <param name="logger">logger</param>
        public IntentFactory(IEnumerable <IIntent> intents, ILogger <IntentFactory> logger)
        {
            if (intents == null || intents.Count() == 0)
            {
                throw new ArgumentNullException(nameof(intents));
            }

            this.logger = logger;

            this.knownIntents   = intents.Where(x => !x.IsFallbackIntent).ToList();
            this.fallbackIntent = intents.LastOrDefault(x => x.IsFallbackIntent) ?? throw new InvalidOperationException("No fall back intent registered!");
        }
示例#23
0
 public override void Handle(IIntent<LightingValue> obj)
 {
     if (obj is StaticArrayIntent<LightingValue>) {
         Func<TimeSpan, Color> scg = x => obj.GetStateAt(x).TrueFullColorWithAlpha;
         Func<TimeSpan, Color> ecg = x => obj.GetStateAt(x - _oneTick).TrueFullColorWithAlpha;
         DrawStaticArrayIntent(_endTime, _rect, scg, ecg);
     } else {
         Color startColor = obj.GetStateAt(_startOffset).TrueFullColorWithAlpha;
         Color endColor = obj.GetStateAt(_endTime - (_endTime<obj.TimeSpan?TimeSpan.Zero:_oneTick)).TrueFullColorWithAlpha;
         DrawGradient(startColor, endColor, _rect);
     }
 }
示例#24
0
        public void Rasterize(IIntent intent, RectangleF rect, Graphics g)
        {
            // As recommended by R#
            if (Math.Abs(rect.Width - 0) < float.Epsilon || Math.Abs(rect.Height - 0) < float.Epsilon)
            {
                return;
            }

            _rect     = rect;
            _graphics = g;

            intent.Dispatch(this);
        }
        /// <summary>
        /// Creates content for a tab with the specified intent, or returns
        /// null if creation is not possible.
        /// </summary>
        /// <remarks>
        /// The intent manager calls this method when it searches for a
        /// factory that can create an <see cref="ITabContent"/> for the
        /// specified intent.
        /// </remarks>
        public ITabContent CreateContent(IIntent intent)
        {
            // This class can handle IDomainToolsTabIntent instances.
            // This code opens a tab with the implementation of
            // IDomainToolsTabViewModel as the view model behind the
            // tab content. HandleIntent() is then called on that view model.
            if (intent is IDomainToolsTabIntent)
            {
                return mTabViewModelProvider.GetInstance();
            }

            // This tab factory cannot create content for the given intent.
            return null;
        }
示例#26
0
        /// <summary>
        /// Creates content for a tab with the specified intent, or returns
        /// null if creation is not possible.
        /// </summary>
        /// <remarks>
        /// The intent manager calls this method when it searches for a
        /// factory that can create an <see cref="ITabContent"/> for the
        /// specified intent.
        /// </remarks>
        public ITabContent CreateContent(IIntent intent)
        {
            // This class can handle IDomainToolsTabIntent instances.
            // This code opens a tab with the implementation of
            // IDomainToolsTabViewModel as the view model behind the
            // tab content. HandleIntent() is then called on that view model.
            if (intent is IDomainToolsTabIntent)
            {
                return(mTabViewModelProvider.GetInstance());
            }

            // This tab factory cannot create content for the given intent.
            return(null);
        }
示例#27
0
        /// <summary>
        /// Creates content for a tab with the specfied intent, or returns
        /// null if creation is not possible.
        /// </summary>
        /// <remarks>
        /// The intent manager calls this method when it searches for a
        /// factory that can create an <see cref="ITabContent"/> for the
        /// specified intent.
        /// </remarks>
        public ITabContent CreateContent(IIntent intent)
        {
            // This class can handle ISubsettingTabIntent instances.
            // This code opens a tab with the implementation of
            // ISubsettingTabViewModel as the view model behind the tab
            // content. HandleIntent() is then called on that view model.
            if (intent is ISubsettingTabIntent)
            {
                return(mTabViewModelProvider.GetInstance());
            }

            // This tab factory cannot create content for other intents.
            return(null);
        }
        /// <summary>
        /// Creates content for a tab with the specfied intent, or returns
        /// null if creation is not possible.
        /// </summary>
        /// <remarks>
        /// The intent manager calls this method when it searches for a
        /// factory that can create an <see cref="ITabContent"/> for the
        /// specified intent.
        /// </remarks>
        public ITabContent CreateContent(IIntent intent)
        {
            // This class can handle ISubsettingTabIntent instances.
            // This code opens a tab with the implementation of
            // ISubsettingTabViewModel as the view model behind the tab
            // content. HandleIntent() is then called on that view model.
            if (intent is ISubsettingTabIntent)
            {
                return mTabViewModelProvider.GetInstance();
            }

            // This tab factory cannot create content for other intents.
            return null;
        }
示例#29
0
        public ITestResult Run(IIntent intent, ITestProvider provider)
        {
            if (provider.Ignored)
            {
                return(_resultFactory.CreateIgnoredTestResult(provider));
            }

            _listener.OnTestStarted(intent);

            IOutputRecording outputRecording;
            var operationResults     = new List <IOperationResult>();
            var cleanupProviderStack = new Stack <IOperationProvider>();
            var stopWatch            = Stopwatch.StartNew();

            using (outputRecording = _resultFactory.CreateOutputRecording())
            {
                // TODO: Repetition with ContextRunner
                foreach (var operationProvider in provider.OperationProviders)
                {
                    Trace.Assert(
                        !cleanupProviderStack.Contains(operationProvider) || operationProvider == cleanupProviderStack.Pop(),
                        string.Format("Cleanup ({0}) is not in order to setup.", operationProvider.Action));

                    var operationResult = _operationRunner.Run(operationProvider);
                    operationResults.Add(operationResult);

                    if (operationResult.State == State.Failed && operationResult.Type != OperationType.Assertion)
                    {
                        break;
                    }

                    if (operationProvider.CleanupProvider != null)
                    {
                        cleanupProviderStack.Push(operationProvider.CleanupProvider);
                    }
                }

                Trace.Assert(
                    !cleanupProviderStack.Any() || operationResults.Any(x => x.State == State.Failed),
                    "Either cleanup stack must be empty, or any result must have failed.");

                operationResults.AddRange(cleanupProviderStack.Select(_operationRunner.Run));
            }

            var result = _resultFactory.CreateTestResult(provider, stopWatch.Elapsed, outputRecording, operationResults);

            _listener.OnTestFinished(result);

            return(result);
        }
示例#30
0
        public void Rasterize(IIntent intent, RectangleF rect, Graphics g, TimeSpan startOffset, TimeSpan endTime)
        {
            // As recommended by R#
            if (Math.Abs(rect.Width - 0) < float.Epsilon || Math.Abs(rect.Height - 0) < float.Epsilon)
            {
                return;
            }

            _rect        = rect;
            _graphics    = g;
            _startOffset = startOffset;
            _endTime     = endTime;

            intent.Dispatch(this);
        }
示例#31
0
 public override void Handle(IIntent <LightingValue> obj)
 {
     if (obj is StaticArrayIntent <LightingValue> )
     {
         Func <TimeSpan, Color> scg = x => obj.GetStateAt(x).FullColorWithAplha;
         Func <TimeSpan, Color> ecg = x => obj.GetStateAt(x - _oneTick).FullColorWithAplha;
         DrawStaticArrayIntent(obj.TimeSpan, _rect, scg, ecg);
     }
     else
     {
         Color startColor = obj.GetStateAt(TimeSpan.Zero).FullColorWithAplha;
         Color endColor   = obj.GetStateAt(obj.TimeSpan - _oneTick).FullColorWithAplha;
         DrawGradient(startColor, endColor, _rect);
     }
 }
示例#32
0
        private Vector2 MapIntentToDirection(IIntent intent)
        {
            switch (intent)
            {
            case MovePlayerLeftIntent _: return(new Vector2(-1, 0));

            case MovePlayerRightIntent _: return(new Vector2(1, 0));

            case MovePlayerUpIntent _: return(new Vector2(0, -1));

            case MovePlayerDownIntent _: return(new Vector2(0, 1));

            default: return(Vector2.Zero);
            }
        }
示例#33
0
 public override void Handle(IIntent <RGBValue> obj)
 {
     if (obj is StaticArrayIntent <RGBValue> )
     {
         Func <TimeSpan, Color> scg = x => obj.GetStateAt(x).ColorWithAplha;
         Func <TimeSpan, Color> ecg = x => obj.GetStateAt(x - _oneTick).ColorWithAplha;
         DrawStaticArrayIntent(_endTime, _rect, scg, ecg);
     }
     else
     {
         Color startColor = obj.GetStateAt(_startOffset).ColorWithAplha;
         Color endColor   = obj.GetStateAt(_endTime - (_endTime < obj.TimeSpan ? TimeSpan.Zero : _oneTick)).ColorWithAplha;
         DrawGradient(startColor, endColor, _rect);
     }
 }
示例#34
0
        public ISuiteResult Run(IIntent intent, ISuiteProvider provider)
        {
            if (provider.Ignored)
            {
                return(_resultFactory.CreateIgnoredSuiteResult(provider));
            }

            using (_resourceManager.Acquire(provider.Resources))
            {
                var suitePairs = Pair(intent.Intents, provider.SuiteProviders);
                var testPairs  = Pair(intent.Intents, provider.TestProviders);

                return(RunWithResourcesAcquired(intent, provider, suitePairs, testPairs));
            }
        }
示例#35
0
        private ISuiteResult RunAssemblySuites(
            Assembly assembly,
            [CanBeNull] string cachePath,
            ICancellationTokenSource cancellationTokenSource,
            IIntent assemblyIntent)
        {
            using (var appDomain = _appDomainFactory.Create(assembly, cachePath))
            {
                var cancellation          = appDomain.CreateProxy <ICancellation>(typeof(CrossAppDomainCancellation));
                var assemblyRunnerFactory = appDomain.CreateProxy <IAssemblyRunnerFactory>(typeof(AssemblyRunnerFactory));

                var assemblyRunner = assemblyRunnerFactory.Create(_listener, _resourceManager, cancellation);
                cancellationTokenSource.Token.Register(cancellation.Cancel);

                return(assemblyRunner.Run(assemblyIntent));
            }
        }
示例#36
0
        /// <inheritdoc />
        public void HandleIntent(IIntent intent, OpenTabOptions options)
        {
            // Handle the intent
            var    tabIntent = (IDomainToolsTabIntent)intent;
            string url       = mBaseURL;

            if (tabIntent.Type != null)
            {
                url += "?type=" + tabIntent.Type;
                if (tabIntent.Query != null)
                {
                    url += "&query=" + tabIntent.Query;
                }
            }
            PageLocation = url;
            SetAsViewModelForView(View);
        }
示例#37
0
        private ISuiteResult RunWithResourcesAcquired(
            IIntent intent,
            ISuiteProvider provider,
            IEnumerable <Tuple <IIntent, ISuiteProvider> > suitePairs,
            IEnumerable <Tuple <IIntent, ITestProvider> > testPairs)
        {
            _listener.OnSuiteStarted(intent, provider.Text);

            IOutputRecording           outputRecording;
            IContextScope              contextScope;
            ICollection <ISuiteResult> suiteResults = new ISuiteResult[0];
            ICollection <ITestResult>  testResults  = new ITestResult[0];

            using (outputRecording = _resultFactory.CreateOutputRecording())
            {
                using (contextScope = _contextRunner.Run(provider.ContextProviders))
                {
                    if (contextScope.SetupResults.All(x => x.State == State.Passed))
                    {
                        suiteResults = suitePairs.AsParallel()
                                       .WithDegreeOfParallelism(degreeOfParallelism: 1)
                                       .WithCancellation(_cancellationTokenSource.Token)
                                       .Select(x => Run(x.Item1, x.Item2)).ToList();

                        testResults = testPairs.AsParallel()
                                      .WithDegreeOfParallelism(degreeOfParallelism: 1)
                                      .WithCancellation(_cancellationTokenSource.Token)
                                      .Select(x => _testRunner.Run(x.Item1, x.Item2)).ToList();
                    }
                }
            }

            var result = _resultFactory.CreateSuiteResult(
                provider,
                outputRecording,
                contextScope.SetupResults,
                contextScope.CleanupResults,
                suiteResults,
                testResults);

            _listener.OnSuiteFinished(result);

            return(result);
        }
示例#38
0
        public ITestResult Run(IIntent intent, ITestProvider provider)
        {
            if (provider.Ignored)
            return _resultFactory.CreateIgnoredTestResult(provider);

              _listener.OnTestStarted(intent);

              IOutputRecording outputRecording;
              var operationResults = new List<IOperationResult>();
              var cleanupProviderStack = new Stack<IOperationProvider>();
              var stopWatch = Stopwatch.StartNew();

              using (outputRecording = _resultFactory.CreateOutputRecording())
              {
            // TODO: Repetition with ContextRunner
            foreach (var operationProvider in provider.OperationProviders)
            {
              Trace.Assert(
              !cleanupProviderStack.Contains(operationProvider) || operationProvider == cleanupProviderStack.Pop(),
              string.Format("Cleanup ({0}) is not in order to setup.", operationProvider.Action));

              var operationResult = _operationRunner.Run(operationProvider);
              operationResults.Add(operationResult);

              if (operationResult.State == State.Failed && operationResult.Type != OperationType.Assertion)
            break;

              if (operationProvider.CleanupProvider != null)
            cleanupProviderStack.Push(operationProvider.CleanupProvider);
            }

            Trace.Assert(
            !cleanupProviderStack.Any() || operationResults.Any(x => x.State == State.Failed),
            "Either cleanup stack must be empty, or any result must have failed.");

            operationResults.AddRange(cleanupProviderStack.Select(_operationRunner.Run));
              }

              var result = _resultFactory.CreateTestResult(provider, stopWatch.Elapsed, outputRecording, operationResults);

              _listener.OnTestFinished(result);

              return result;
        }
示例#39
0
        private static void AddIntentsToElement(Element element, double[] allPointsTimeOrdered, Curve levelCurve, ColorGradient colorGradient, TimeSpan duration, EffectIntents elementData, bool allowZeroIntensity, Color?color = null)
        {
            if (element != null)
            {
                double   lastPosition = allPointsTimeOrdered[0];
                TimeSpan lastEnd      = TimeSpan.Zero;
                for (var i = 1; i < allPointsTimeOrdered.Length; i++)
                {
                    double   position  = allPointsTimeOrdered[i];
                    TimeSpan startTime = lastEnd;
                    TimeSpan timeSpan  = TimeSpan.FromMilliseconds(duration.TotalMilliseconds * (position - lastPosition));

                    if (color == null)
                    {
                        var startColor     = colorGradient.GetColorAt(lastPosition);
                        var endColor       = colorGradient.GetColorAt(position);
                        var startIntensity = levelCurve.GetValue(lastPosition * 100) / 100;
                        var endIntensity   = levelCurve.GetValue(position * 100) / 100;


                        if (allowZeroIntensity || !(startIntensity.Equals(0) && endIntensity.Equals(0)))
                        {
                            IIntent intent = IntentBuilder.CreateIntent(startColor, endColor, startIntensity, endIntensity, timeSpan);
                            elementData.AddIntentForElement(element.Id, intent, startTime);
                        }
                    }
                    else
                    {
                        var startIntensity = (colorGradient.GetProportionOfColorAt(lastPosition, (Color)color) * levelCurve.GetValue(lastPosition * 100) / 100);
                        var endIntensity   = (colorGradient.GetProportionOfColorAt(position, (Color)color) * levelCurve.GetValue(position * 100) / 100);

                        if (allowZeroIntensity || !(startIntensity.Equals(0) && endIntensity.Equals(0)))
                        {
                            IIntent intent = IntentBuilder.CreateDiscreteIntent((Color)color, startIntensity, endIntensity, timeSpan);
                            elementData.AddIntentForElement(element.Id, intent, startTime);
                        }
                    }

                    lastPosition = position;
                    lastEnd      = startTime + timeSpan;
                }
            }
        }
示例#40
0
        protected EffectIntents CreateIntentsForElement(ElementNode element, double intensity, Color color, TimeSpan duration)
        {
            EffectIntents effectIntents = new EffectIntents();

            foreach (ElementNode elementNode in element.GetLeafEnumerator())
            {
                if (HasDiscreteColors && IsElementDiscrete(elementNode))
                {
                    IEnumerable <Color> colors = ColorModule.getValidColorsForElementNode(elementNode, false);
                    if (!colors.Contains(color))
                    {
                        continue;
                    }
                }

                IIntent intent = CreateIntent(elementNode, color, intensity, duration);
                effectIntents.AddIntentForElement(elementNode.Element.Id, intent, TimeSpan.Zero);
            }

            return(effectIntents);
        }
示例#41
0
 private IEnumerable<Type> Filter(IIntent assemblyIntent, IEnumerable<Type> suiteTypes)
 {
     if (!assemblyIntent.Intents.Any())
     return suiteTypes;
       else
     return suiteTypes.Where(x => assemblyIntent.Intents.Any(y => y.Identity.Relative == x.FullName));
 }
示例#42
0
 public void OnTestStarted(IIntent intent)
 {
     _listener.OnTestStarted(intent);
 }
示例#43
0
 public void AddIntent(IIntent intent)
 {
     Trace.Assert(intent.Identity.Parent == null);
       _intents.Add(intent);
 }
示例#44
0
 public void OnTestStarted(IIntent intent)
 {
     _listeners.ForEach(x => x.OnTestStarted(intent));
 }
示例#45
0
 public virtual void Handle(IIntent<LightingValue> obj)
 {
 }
示例#46
0
 public virtual void Handle(IIntent<DiscreteValue> obj)
 {
 }
示例#47
0
 public virtual void Handle(IIntent<CommandValue> obj)
 {
 }
示例#48
0
 public virtual void Handle(IIntent<PositionValue> obj)
 {
 }
        private void RunIntentNearCurrent(IIntent intent)
        {
            // Open the tab next to the current one
            var openTabOptions = new OpenTabOptions
            {
                Location = OpenTabLocation.OpenNearCurrent
            };

            mIntentManager.Run(intent, openTabOptions);
        }
示例#50
0
        private ISuiteResult RunAssemblySuites(
        Assembly assembly,
        [CanBeNull] string cachePath,
        CancellationTokenSource cancellationTokenSource,
        IIntent assemblyIntent)
        {
            using (var appDomain = _appDomainFactory.Create(assembly, cachePath))
              {
            var cancellation = appDomain.CreateProxy<ICancellation>(typeof (CrossAppDomainCancellation));
            var assemblyRunnerFactory = appDomain.CreateProxy<IAssemblyRunnerFactory>(typeof (AssemblyRunnerFactory));

            var assemblyRunner = assemblyRunnerFactory.Create(_listener, _resourceManager, cancellation);
            cancellationTokenSource.Token.Register(cancellation.Cancel);

            return assemblyRunner.Run(assemblyIntent);
              }
        }
示例#51
0
 public virtual void OnTestStarted(IIntent intent)
 {
 }
示例#52
0
 public override void OnSuiteStarted(IIntent intent)
 {
     _writer.WriteTestSuiteStarted(intent.Identity.Absolute);
 }
示例#53
0
 public void OnSuiteStarted(IIntent intent)
 {
     _listener.OnSuiteStarted(intent);
 }
示例#54
0
 public virtual void Handle(IIntent<RGBValue> obj)
 {
 }
示例#55
0
 public void AddIntent(IIntent intent)
 {
     Trace.Assert(Identity.Equals(intent.Identity.Parent));
       _intents.Add(intent);
 }
示例#56
0
 public virtual void Handle(IIntent<IntensityValue> obj)
 {
 }
示例#57
0
 public void SetOutputCurrentState(IntentOutput output, IIntent[] state)
 {
     _outputStates[output] = state;
 }
示例#58
0
 public virtual void OnSuiteStarted(IIntent intent)
 {
 }