private void ValidateRequestParams()
        {
            for (var i = 0; i < _requests.Length; i++)
            {
                try
                {
                    RequiredParamsValidator.Validate(_requests[i].Parameters);

                    CompatibilityValidator.Validate(_requests[i].Parameters, _requests[i], _requests[i].HitType);
                }
                catch (Exception ex)
                {
                    throw new ApplicationException($"Parameters validation failed for request with index = {i} with: {ex.Message}");
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the scenario and verifies the expectations attached to it.
        /// </summary>
        public void Execute()
        {
            Tracer.WriteLine("Validating scenario: {0}", this.Title);
            int stepCount = 1;

            using (Tracer.Indent())
            {
                foreach (var step in _steps)
                {
                    Tracer.Write("Step {0} ", stepCount);
                    try
                    {
                        step.Execute();
                        Tracer.WriteLine("");
                    }
                    catch
                    {
                        Tracer.WriteLine("failed");
                        Tracer.WriteLine("");
                        Tracer.WriteLine("Exception details:");
                        throw;
                    }
                    stepCount++;
                }

                // Ensure no additional events are in the queue
                Tracer.WriteLine("Finalizing: Verifying additional events were not raised.");
                Assert.IsNull(EventMonitor.DequeueNextEvent(), "The test has completed, but there are still events in the queue that were not expected.");

                // Compare with LINQ to Objects
                Tracer.WriteLine("Finalizing: Comparing final results to LINQ to Objects");
                CompatibilityValidator.CompareWithLinq(CompatabilityLevel.FullyCompatible, BindableLinqQuery, StandardLinqQuery);

                // Forget all references to the query and ensure it is garbage collected
                Tracer.WriteLine("Finalizing: Detecting memory leaks and event handlers that have not been unhooked.");
                WeakReference bindableQuery = new WeakReference(this.BindableLinqQuery, false);
                _bindableLinqQuery = null;
                _eventMonitor.Dispose();

                GC.Collect();
                GC.WaitForPendingFinalizers();
                Assert.IsFalse(bindableQuery.IsAlive, "There should be no live references to the bindable query at this point. This may indicate that the query or items within the query have event handlers that have not been unhooked.");
            }
        }
        protected virtual void ValidateRequestParams()
        {
            RequiredParamsValidator.Validate(Parameters);

            CompatibilityValidator.Validate(Parameters, this, HitType);
        }