Inheritance: MonoBehaviour
Exemple #1
0
        public override UpdateResult Update()
        {
            // For this example, we are processing all updates.
            // Normally clients can limit how much they are willing to process per frame.
            StateSnapshot snapshot;

            for (bool hasMoreUpdates = true; hasMoreUpdates;)
            {
                (snapshot, hasMoreUpdates) = _replicatedState.ProcessSingleUpdate(this);
            }
            switch (testStage)
            {
            case TestStage.WaitingForObjectsToAppear:
                if (_objects.Count != 0)
                {
                    TransactionBuilder transactionBuilder = new TransactionBuilder();
                    foreach (KeyValuePair <Guid, SomeObject> value in _objects)
                    {
                        Key key = MakeObjectKey(value.Key);
                        transactionBuilder.Put(key, 0, new byte[] { 0, 0, 0 });
                    }
                    Transaction transaction = transactionBuilder.CreateTransaction();
                    _replicatedState.Commit(transaction);
                    testStage = TestStage.Done;
                    return(UpdateResult.SentTransaction);
                }
                break;

                // TODO: make the exchange more exciting by adding more states
            }
            return(UpdateResult.NothingHappened);
        }
        private TestResourceSnapshot GetTestResourceSnapshot(TestStage testStage, IAssemblyInfo assemblyInfo)
        {
            var timeStamp    = DateTime.UtcNow;
            var assemblyName = GetAssemblyShortName(assemblyInfo);
            var cpuUsage     = _metricCacher.GetValue(MetricCacher.Keys.Server.CpuUsage, _cpuUsageCalculator.Calculate);

            var memoryInfo = _metricCacher.GetValue <MemoryInfoResult>(MetricCacher.Keys.Server.MemoryInfoExtended);

            var snapshot = new TestResourceSnapshot
            {
                TotalScratchAllocatedMemory = new Size(MemoryInformation.GetTotalScratchAllocatedMemory(), SizeUnit.Bytes).GetValue(SizeUnit.Megabytes),
                TotalDirtyMemory            = new Size(MemoryInformation.GetDirtyMemoryState().TotalDirtyInBytes, SizeUnit.Bytes).GetValue(SizeUnit.Megabytes),
                IsHighDirty                = MemoryInformation.GetDirtyMemoryState().IsHighDirty,
                TestStage                  = testStage,
                Timestamp                  = timeStamp.ToString("o"),
                AssemblyName               = assemblyName,
                MachineCpuUsage            = (long)cpuUsage.MachineCpuUsage,
                ProcessCpuUsage            = (long)cpuUsage.ProcessCpuUsage,
                ProcessMemoryUsageInMb     = memoryInfo.WorkingSet.GetValue(SizeUnit.Megabytes),
                TotalMemoryInMb            = memoryInfo.TotalPhysicalMemory.GetValue(SizeUnit.Megabytes),
                TotalCommittableMemoryInMb = memoryInfo.TotalCommittableMemory.GetValue(SizeUnit.Megabytes),
                AvailableMemoryInMb        = memoryInfo.AvailableMemory.GetValue(SizeUnit.Megabytes),
                CurrentCommitChargeInMb    = memoryInfo.CurrentCommitCharge.GetValue(SizeUnit.Megabytes),
                SharedCleanMemoryInMb      = memoryInfo.SharedCleanMemory.GetValue(SizeUnit.Megabytes),
                TotalScratchDirtyMemory    = memoryInfo.TotalScratchDirtyMemory.GetValue(SizeUnit.Megabytes)
            };

            return(snapshot);
        }
Exemple #3
0
        public override UpdateResult Update()
        {
            // For this example, we are processing all updates.
            // Normally clients can limit how much they are willing to process per frame.
            StateSnapshot snapshot;

            for (bool hasMoreUpdates = true; hasMoreUpdates;)
            {
                (snapshot, hasMoreUpdates) = _replicatedState.ProcessSingleUpdate(this);
            }
            switch (testStage)
            {
            case TestStage.WantsToCreateAnObject:
                TransactionBuilder transactionBuilder = new TransactionBuilder();
                createdObjectGuid = Guid.NewGuid();
                createdObjectKey  = MakeObjectKey(createdObjectGuid);

                transactionBuilder.RequireSubkeysCount(createdObjectKey, 0);
                transactionBuilder.Put(createdObjectKey, 0, new byte[] { 1, 2, 3 });
                transactionBuilder.Put(createdObjectKey, 1, new byte[] { 4, 5, 6 });
                transactionBuilder.Put(createdObjectKey, 2, new byte[] { 7, 8, 9 });

                Transaction transaction = transactionBuilder.CreateTransaction();

                _replicatedState.Commit(transaction);
                testStage = TestStage.WaitingForModificationByOtherClient;
                return(UpdateResult.SentTransaction);
                // TODO: make the exchange more exciting by adding more states
            }
            return(UpdateResult.NothingHappened);
        }
Exemple #4
0
        private void ExecuteSteps(IEnumerable <TestStepBase> testSteps, TestStage stage)
        {
            _logger.TestStageStart(stage, DateTime.Now);
            _context.SetTestStage(stage);

            try
            {
                if (null == testSteps)
                {
                    return;
                }

                foreach (var step in testSteps)
                {
                    ExecuteXamlTestStep(step, stage);
                }

                FlushConcurrentQueue(true, stage);
            }
            catch (Exception e)
            {
                // If we caught an exception on the main test execution, save it, perform cleanup,
                // then throw the exception...
                _executionException = e;
            }

            _logger.TestStageEnd(stage, DateTime.Now, _executionException);
        }
Exemple #5
0
        public override void OnTransactionApplied(OnTransactionAppliedArgs args)
        {
            // There are multiple ways we can react to the change.
            // We could subscribe to the update, we could check the state of the object,
            // we could validate either the data or the version of the object in the snapshot,
            // or we can just wait for global updates of the state.
            // Here we pick the last option.
            base.OnTransactionApplied(args);
            switch (testStage)
            {
            case TestStage.WaitingForObjectCreation:
                if (!args.insertedKeys.IsEmpty)
                {
                    testStage = TestStage.WaitingForModificationByOtherClient;
                }
                break;

            case TestStage.WaitingForModificationByOtherClient:
                if (!args.updatedKeys.IsEmpty)
                {
                    testStage = TestStage.Done;
                }
                break;
            }
        }
Exemple #6
0
 /// <summary>
 ///     TestStepExecutionException constructor.
 /// </summary>
 /// <param name="message">The message associated with this exception.</param>
 /// <param name="stage"></param>
 /// <param name="testCaseName">The name of the BizUnit test case executing whilst the validation step failed.</param>
 /// <param name="testStepName"></param>
 /// <remarks>
 ///     The following example demonstrates how to create and call BizUnit using
 ///     the BizUnit Test Case Object Model:
 /// </remarks>
 public TestStepExecutionException(string message, TestStage stage, string testCaseName, string testStepName)
     : base(message)
 {
     _stage        = stage;
     _testCaseName = testCaseName;
     _testStepName = testStepName;
 }
Exemple #7
0
        public void Start()
        {
            debugInput.Initialize();
            testStage = new TestStage(levelData);

            bulletFactory = new BulletFactory(originalBullet, levelData);

            // プレイヤー
            playerModel = new PlayerModel(testStage.LevelData, testStage);
            playerPresenter.Initialize(playerModel, debugInput, testStage);
            playerModel.OnAttackObservable.Subscribe(attacker => {
                // 弾生成
                if (playerBullet == null)
                {
                    playerBullet = bulletFactory.CreateBullet(attacker);

                    playerBullet.OnDestroy.Subscribe(_ => {
                        playerBullet = null;
                    }).AddTo(this);
                }
            }).AddTo(this);

            // 敵
            enemyArmy = new EnemyArmy(testStage);
        }
Exemple #8
0
 private static void ValidateSteps(IEnumerable <TestStepBase> steps, TestStage stage, Context ctx)
 {
     // Validate test Setup Steps
     foreach (var step in steps)
     {
         Exception caughtEx = null;
         try
         {
             step.Validate(ctx);
             if (null != step.SubSteps)
             {
                 foreach (var subStep in step.SubSteps)
                 {
                     subStep.Validate(ctx);
                 }
             }
         }
         catch (Exception ex)
         {
             caughtEx = ex;
             throw;
         }
         finally
         {
             ctx.Logger.ValidateTestSteps(stage, step.GetType().ToString(), caughtEx);
         }
     }
 }
Exemple #9
0
        public void When_adding()
        {
            var stage = new TestStage();

            _builder.Add(stage);
            _builder.ToStages().ShouldBe(new[] { _stageOne, _stageTwo, stage });
        }
 /// <summary>
 /// TestStepExecutionException constructor.
 /// </summary>
 /// <param name="message">The message associated with this exception.</param>
 /// <param name="testCaseName">The name of the BizUnit test case executing whilst the validation step failed.</param>
 /// 
 /// <remarks>
 /// The following example demonstrates how to create and call BizUnit using 
 /// the BizUnit Test Case Object Model:
 ///	</remarks>
 public TestStepExecutionException(string message, TestStage stage, string testCaseName, string testStepName)
     : base(message) 
 {
     Stage = stage;
     TestCaseName = testCaseName;
     TestStepName = testStepName;
 }
Exemple #11
0
        /// <summary>
        /// Used to add a test step to a test case at a specific stage of the test.
        /// </summary>
        ///
        /// <param name='testStep'>The test step to add to the test case.</param>
        /// <param name='stage'>The stage of the test case in which to add the test step</param>
        /// <param name='runConcurrently'>Specifies whether the test step
        /// should run concurrently to other test steps. Defaults to false if not specified.</param>
        /// <param name='failOnError'>Specifies whether the entire test case
        /// should fail if this individual test step fails, defaults to true if not specified.</param>
        public void AddTestStep(ITestStepOM testStep, TestStage stage, bool runConcurrently, bool failOnError)
        {
            ArgumentValidation.CheckForNullReference(testStep, "testStep");
            ArgumentValidation.CheckForNullReference(stage, "stage");

            AddTestStepInternal(new BizUnitTestStepWrapper(testStep, runConcurrently, failOnError), stage);
        }
Exemple #12
0
        public void When_starting_with()
        {
            var stage = new TestStage();

            _builder.StartWith(stage);

            _builder.ToStages().ShouldBe(new[] { stage, _stageOne, _stageTwo });
        }
Exemple #13
0
                public Logic(TestStage stage) : base(stage.Shape)
                {
                    _stage = stage;

                    SetHandler(stage.Inlet, onPush: () => Push(stage.Outlet, Grab(stage.Inlet)));

                    SetHandler(stage.Outlet, onPull: () => Pull(stage.Inlet));
                }
Exemple #14
0
        public void When_ending_with()
        {
            var stage = new TestStage();

            _builder.EndWith(stage);

            _builder.ToStages().ShouldBe(new[] { stage });
        }
Exemple #15
0
        public void When_adding_after_last()
        {
            var stage = new TestStage();

            _builder.AddAfter <StageTwo>(stage);

            _builder.ToStages().ShouldBe(new[] { _stageOne, _stageTwo, stage });
        }
Exemple #16
0
        public void When_adding_before_last()
        {
            var stage = new TestStage();

            _builder.AddBefore <StageTwo>(stage);

            _builder.ToStages().ShouldBe(new[] { _stageOne, stage, _stageTwo });
        }
        public void WriteResourceSnapshot(TestStage testStage, ITestClass testClass)
        {
            var snapshot = GetTestResourceSnapshot(testStage, testClass.Class.Assembly);

            snapshot.ClassName = testClass.Class.Name;

            Write(snapshot);
        }
Exemple #18
0
#pragma warning disable CS1573 // Parameter 'stage' has no matching param tag in the XML comment for 'TestStepExecutionException.TestStepExecutionException(string, TestStage, string, string)' (but other parameters do)
#pragma warning disable CS1573 // Parameter 'testStepName' has no matching param tag in the XML comment for 'TestStepExecutionException.TestStepExecutionException(string, TestStage, string, string)' (but other parameters do)
        /// <summary>
        /// TestStepExecutionException constructor.
        /// </summary>
        /// <param name="message">The message associated with this exception.</param>
        /// <param name="testCaseName">The name of the BizUnit test case executing whilst the validation step failed.</param>
        ///
        /// <remarks>
        /// The following example demonstrates how to create and call BizUnit using
        /// the BizUnit Test Case Object Model:
        ///	</remarks>
        public TestStepExecutionException(string message, TestStage stage, string testCaseName, string testStepName)
#pragma warning restore CS1573 // Parameter 'testStepName' has no matching param tag in the XML comment for 'TestStepExecutionException.TestStepExecutionException(string, TestStage, string, string)' (but other parameters do)
#pragma warning restore CS1573 // Parameter 'stage' has no matching param tag in the XML comment for 'TestStepExecutionException.TestStepExecutionException(string, TestStage, string, string)' (but other parameters do)
            : base(message)
        {
            Stage        = stage;
            TestCaseName = testCaseName;
            TestStepName = testStepName;
        }
 /// <summary>
 /// get the test stage text
 /// </summary>
 /// <returns>text</returns>
 public string GetTestStage()
 {
     TestStage.Wait(2);
     if (Driver.WrappedDriver.GetType() == typeof(DummyDriver))
     {
         TestStage.Text = FakeText;
     }
     return(TestStage.Text);
 }
Exemple #20
0
 /// <summary>
 /// the constructor
 /// </summary>
 /// <param name="testStage">the test stage, default to "Not Specified"</param>
 /// <param name="overrideControlPrefix">override control prefix</param>
 public ViewTestDetailsSideBar(TestStage testStage, string overrideControlPrefix = null)
     : base()
 {
     if (overrideControlPrefix != null)
     {
         this.ControlPrefix = overrideControlPrefix;
     }
     TestStage = testStage;
     InitElements();
 }
 /// <summary>
 /// constrcutor
 /// </summary>
 /// <param name="testStage">the test stage, default to "Not Specified"</param>
 public ViewTestDetailsPage(TestStage testStage = TestStage.NotSpecified)
     : base()
 {
     this.Name = MethodBase.GetCurrentMethod().DeclaringType.Name;
     this.PrintName();
     this.ExpectedUrl = "Assess/ViewTestDetails.aspx";
     this.VerifyCurrentUrl();
     this.testStage = testStage;
     InitElements();
 }
Exemple #22
0
        /// <summary>
        /// </summary>
        public void TestStageEnd(TestStage stage, DateTime time, Exception stageException)
        {
            if (null != stageException)
            {
                LogException(stageException);
            }

            WriteLine(" ");
            WriteLine(null == stageException ? "{0} Stage: ended @ {1}" : "{0} Stage: ended @ {1} with ERROR's", stage,
                      FormatDate(time));
        }
        /// <summary>
        /// Records a harness state for the unit test harness.
        /// </summary>
        /// <param name="harness">The unit test harness.</param>
        /// <param name="name">The harness name.</param>
        /// <param name="stage">The test stage.</param>
        public void UnitTestHarnessStage(UnitTestHarness harness, string name, TestStage stage)
        {
            LogMessage m = Create(LogMessageType.TestExecution, name);

            MarkUnitTestMessage(m);
            DecorateNameProperty(m, name);
            DecorateTestGranularity(m, TestGranularity.Harness);
            m[UnitTestLogDecorator.UnitTestHarness] = harness;
            DecorateTestStage(m, stage);
            Enqueue(m);
        }
Exemple #24
0
        public static void setTestStage(TestStage stage)
        {
            if (stage == testStage)
            {
                return;
            }

            testStage = stage;

            updateWindowStatus();
        }
Exemple #25
0
 public void ValidateTestSteps(TestStage stage, string testStepName, Exception ex)
 {
     if (null == ex)
     {
         WriteLine(string.Format("Test step validation for stage: {0}, step: {1} was successful.", stage, testStepName));
     }
     else
     {
         WriteLine(string.Format("Test step validation for stage: {0}, step: {1} failed: {2}", stage, testStepName, ex));
     }
 }
        /// <summary>
        /// Log a test class's stage.
        /// </summary>
        /// <param name="test">The test class metadata object.</param>
        /// <param name="stage">The test stage.</param>
        public void TestClassStage(ITestClass test, TestStage stage)
        {
            TestGranularity granularity = TestGranularity.Test;
            LogMessage      m           = Create(LogMessageType.TestExecution, test.Name);

            MarkUnitTestMessage(m);
            DecorateNameProperty(m, test.Name);
            DecorateTestGranularity(m, granularity);
            m[UnitTestLogDecorator.TestClassMetadata] = test;
            DecorateTestStage(m, stage);
            Enqueue(m);
        }
        /// <summary>
        /// Log a test method's stage.
        /// </summary>
        /// <param name="method">The test method metadata object.</param>
        /// <param name="stage">The test stage.</param>
        public void TestMethodStage(ITestMethod method, TestStage stage)
        {
            TestGranularity granularity = TestGranularity.TestScenario;
            LogMessage      m           = Create(LogMessageType.TestExecution, method.Name);

            MarkUnitTestMessage(m);
            DecorateNameProperty(m, method.Name);
            DecorateTestGranularity(m, granularity);
            m[UnitTestLogDecorator.TestMethodMetadata] = method;
            DecorateTestStage(m, stage);
            Enqueue(m);
        }
Exemple #28
0
        /// <summary>
        /// Conditional check, if the message is of a granular nature, a test
        /// group, and in the finishing stage.
        /// </summary>
        /// <param name="message">The log message.</param>
        /// <returns>Returns true when the conditions are met.</returns>
        private bool MarksTestGroupCompletion(LogMessage message)
        {
            if (message.HasDecorators(LogDecorator.TestGranularity, LogDecorator.TestStage))
            {
                TestGranularity granularity = (TestGranularity)message[LogDecorator.TestGranularity];
                TestStage       stage       = (TestStage)message[LogDecorator.TestStage];

                bool ok = granularity == TestGranularity.TestGroup || granularity == TestGranularity.Harness;
                return(ok && stage == TestStage.Finishing);
            }
            return(false);
        }
Exemple #29
0
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'Logger.ValidateTestSteps(TestStage, string, Exception)'
        public void ValidateTestSteps(TestStage stage, string testStepName, Exception ex)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'Logger.ValidateTestSteps(TestStage, string, Exception)'
        {
            if (null == ex)
            {
                WriteLine(string.Format("Test step validation for stage: {0}, step: {1} was successful.", stage, testStepName));
            }
            else
            {
                WriteLine(string.Format("Test step validation for stage: {0}, step: {1} failed: {2}", stage, testStepName, ex));
            }
        }
Exemple #30
0
        /// <summary>
        /// Used to add a test step to a test case at a specific stage of the test.
        /// </summary>
        ///
        /// <param name='testStep'>The test step to add to the test case.</param>
        /// <param name='config'>The configuration for the test step to be used when it is executed.</param>
        /// <param name='stage'>The stage of the test case in which to add the test step</param>
        /// <param name='runConcurrently'>Specifies whether the test step
        /// should run concurrently to other test steps. Defaults to false if not specified.</param>
        /// <param name='failOnError'>Specifies whether the entire test case
        /// should fail if this individual test step fails, defaults to true if not specified.</param>
        public void AddTestStep(ITestStep testStep, string config, TestStage stage, bool runConcurrently, bool failOnError)
        {
            ArgumentValidation.CheckForNullReference(testStep, "testStep");
            ArgumentValidation.CheckForNullReference(config, "config");

            var doc = new XmlDocument();

            doc.LoadXml(config);
            XmlNode configNode = doc.DocumentElement;

            AddTestStepInternal(new BizUnitTestStepWrapper(testStep, configNode, runConcurrently, failOnError), stage);
        }
        public void WriteResourceSnapshot(TestStage testStage, ITestMethod testMethod, TestResult?testResult = null)
        {
            var testClass = testMethod.TestClass.Class;

            var snapshot = GetTestResourceSnapshot(testStage, testClass.Assembly);

            snapshot.ClassName  = testClass.Name;
            snapshot.MethodName = testMethod.Method.Name;
            snapshot.TestResult = testResult;

            Write(snapshot);
        }
        public void GranularAssemblyTestStage(IAssembly assembly, TestGranularity granularity, TestStage stage)
        {
            string message = granularity.ToString() + assembly.Name + " " + stage.ToString().ToLower(System.Globalization.CultureInfo.InvariantCulture);
            string name = assembly.Name;

            LogMessage m = Create(LogMessageType.TestExecution, message);
            MarkUnitTestMessage(m);
            DecorateNameProperty(m, name);
            DecorateTestGranularity(m, granularity);
            m[UnitTestLogDecorator.TestAssemblyMetadata] = assembly;
            DecorateTestStage(m, stage);
            Enqueue(m);
        }
Exemple #33
0
        public void TestStageEnd(TestStage stage, DateTime time, Exception stageException)
        {
            if (null != stageException)
            {
                LogException(stageException);
            }

            WriteLine(" ");
            if (null == stageException)
            {
                WriteLine("{0} Stage: ended @ {1}", stage, FormatDate(time));
            }
            else
            {
                WriteLine("{0} Stage: ended @ {1} with ERROR's", stage, FormatDate(time));
            }
        }
Exemple #34
0
        public void TestStageStart(TestStage stage, DateTime time)
        {
            switch(stage)
            {
                case TestStage.Setup:
                    WriteLine(" ");
                    WriteLine("Setup Stage: started @ {0}", FormatDate(time));
                    break;

                case TestStage.Execution:
                    WriteLine(" ");
                    WriteLine("Execute Stage: started @ {0}", FormatDate(time));
                    break;

                case TestStage.Cleanup:
                    WriteLine(" ");
                    WriteLine("Cleanup Stage: started @ {0}", FormatDate(time));
                    break;
            }
        }
Exemple #35
0
        private void FlushConcurrentQueue(bool waitingToFinish, TestStage stage)
        {
            if (waitingToFinish && _inflightQueueDepth == 0)
            {
                return;
            }

            while ((_completedConcurrentSteps.Count > 0) || waitingToFinish)
            {
                object obj = null;

                lock (_completedConcurrentSteps.SyncRoot)
                {
                    if (_completedConcurrentSteps.Count > 0)
                    {
                        try
                        {
                            obj = _completedConcurrentSteps.Dequeue();
                        }
                        catch (Exception ex)
                        {
                            _logger.LogException(ex);
                        }
                    }
                }

                if (null != obj)
                {
                    var step = (ConcurrentTestStepWrapper)obj;
                    _logger.LogBufferedText(step.Logger);

                    _logger.TestStepEnd(step.Name, DateTime.Now, step.FailureException);

                    // Check to see if the test step failed, if it did throw the exception...
                    if (null != step.FailureException)
                    {
                        Interlocked.Decrement(ref _inflightQueueDepth);

                        if (step.FailOnError)
                        {
                            if (step.FailureException is ValidationStepExecutionException)
                            {
                                throw step.FailureException;
                            }
                            else
                            {
                                var tsee = new TestStepExecutionException("BizUnit encountered an error concurrently executing a test step", step.FailureException, stage, _testName, step.StepName);
                                throw tsee;
                            }
                        }
                    }
                    else
                    {
                        Interlocked.Decrement(ref _inflightQueueDepth);
                    }
                }

                if (waitingToFinish && (_inflightQueueDepth > 0))
                {
                    Thread.Sleep(250);
                }
                else if (waitingToFinish && (_inflightQueueDepth == 0))
                {
                    break;
                }
            }
        }
 /// <summary>
 /// Log a test class's stage.
 /// </summary>
 /// <param name="test">The test class metadata object.</param>
 /// <param name="stage">The test stage.</param>
 public void TestClassStage(ITestClass test, TestStage stage)
 {
   TestGranularity granularity = TestGranularity.Test;
   LogMessage m = Create(LogMessageType.TestExecution, test.Name);
   MarkUnitTestMessage(m);
   DecorateNameProperty(m, test.Name);
   DecorateTestGranularity(m, granularity);
   m[UnitTestLogDecorator.TestClassMetadata] = test;
   DecorateTestStage(m, stage);
   Enqueue(m);
 }
Exemple #37
0
        private void ExecuteSteps(XmlNodeList steps, TestStage stage)
        {
            if (null == steps)
            {
                return;
            }

            foreach (XmlNode stepConfig in steps)
            {
                var stepWrapper = new BizUnitTestStepWrapper(stepConfig);
                ExecuteTestStep(stepWrapper, stage);
            }

            FlushConcurrentQueue(true, stage);
        }
Exemple #38
0
        public void ValidateTestSteps(TestStage stage, string testStepName, Exception ex)
	    {
            if (null == ex)
            {
                WriteLine(string.Format("Test step validation for stage: {0}, step: {1} was successful.", stage, testStepName));
            }
            else
            {
                WriteLine(string.Format("Test step validation for stage: {0}, step: {1} failed: {2}", stage, testStepName, ex));
            }
        }
Exemple #39
0
 /// <summary>
 /// Used to add a test step to a test case at a specific stage of the test.
 /// </summary>
 /// 
 /// <param name='testStep'>The test step to add to the test case.</param>
 /// <param name='stage'>The stage of the test case in which to add the test step</param>
 public void AddTestStep(ITestStepOM testStep, TestStage stage)
 {
     AddTestStep(testStep, stage, false, true);
 }
Exemple #40
0
        /// <summary>
        /// Used to add a test step to a test case at a specific stage of the test.
        /// </summary>
        /// 
        /// <param name='testStep'>The test step to add to the test case.</param>
        /// <param name='config'>The configuration for the test step to be used when it is executed.</param>
        /// <param name='stage'>The stage of the test case in which to add the test step</param>
        /// <param name='runConcurrently'>Specifies whether the test step 
        /// should run concurrently to other test steps. Defaults to false if not specified.</param>
        /// <param name='failOnError'>Specifies whether the entire test case 
        /// should fail if this individual test step fails, defaults to true if not specified.</param>
        public void AddTestStep(ITestStep testStep, string config, TestStage stage, bool runConcurrently, bool failOnError)
        {
            ArgumentValidation.CheckForNullReference(testStep, "testStep");
            ArgumentValidation.CheckForNullReference(config, "config");

            var doc = new XmlDocument();
            doc.LoadXml(config);
            XmlNode configNode = doc.DocumentElement;

            AddTestStepInternal(new BizUnitTestStepWrapper(testStep, configNode, runConcurrently, failOnError), stage);
        }
 internal TestStepEventArgs(TestStage stage, string testCaseName, string testStepTypeName)
 {
     Stage = stage;
     TestCaseName = testCaseName;
     TestStepTypeName = testStepTypeName;
 }
Exemple #42
0
        private void ExecuteSteps(IEnumerable<TestStepBase> testSteps, TestStage stage)
        {
            _logger.TestStageStart(stage, DateTime.Now);
            _context.SetTestStage(stage);

            try
            {
                if (null == testSteps)
                {
                    return;
                }

                foreach (var step in testSteps)
                {
                    ExecuteXamlTestStep(step, stage);
                }

                FlushConcurrentQueue(true, stage);
            }
            catch (Exception e)
            {
                // If we caught an exception on the main test execution, save it, perform cleanup,
                // then throw the exception...
                _executionException = e;
            }

            _logger.TestStageEnd(stage, DateTime.Now, _executionException);
        }
Exemple #43
0
 internal void SetTestStage(TestStage currentStage)
 {
     CurrentTestStage = currentStage;
 }
Exemple #44
0
        private void ExecuteXamlTestStep(TestStepBase testStep, TestStage stage)
        {
            try
            {
                // Should this step be executed concurrently?
                if (testStep.RunConcurrently)
                {
                    _context.LogInfo("Queuing concurrent step: {0} for execution", testStep.GetType().ToString());
                    Interlocked.Increment(ref _inflightQueueDepth);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(WorkerThreadThunk), new ConcurrentTestStepWrapper(testStep, _context));
                }
                else
                {
                    _logger.TestStepStart(testStep.GetType().ToString(), DateTime.Now, false, testStep.FailOnError);
                    if (testStep is ImportTestCaseStep)
                    {
                        ExecuteImportedTestCase(testStep as ImportTestCaseStep, _context);
                    }
                    else
                    {
                        testStep.Execute(_context);
                    }
                }
            }
            catch (Exception e)
            {
                _logger.TestStepEnd(testStep.GetType().ToString(), DateTime.Now, e);

                if (testStep.FailOnError)
                {
                    if (e is ValidationStepExecutionException)
                    {
                        throw;
                    }

                    var tsee = new TestStepExecutionException("BizUnit encountered an error executing a test step", e, stage, _testName, testStep.GetType().ToString());
                    throw tsee;
                }
            }

            if (!testStep.RunConcurrently)
            {
                _logger.TestStepEnd(testStep.GetType().ToString(), DateTime.Now, null);
            }

            FlushConcurrentQueue(false, stage);
        }
Exemple #45
0
        /// <summary>
        /// Used to add a test step to a test case at a specific stage of the test.
        /// </summary>
        /// 
        /// <param name='testStep'>The test step to add to the test case.</param>
        /// <param name='stage'>The stage of the test case in which to add the test step</param>
        /// <param name='runConcurrently'>Specifies whether the test step 
        /// should run concurrently to other test steps. Defaults to false if not specified.</param>
        /// <param name='failOnError'>Specifies whether the entire test case 
        /// should fail if this individual test step fails, defaults to true if not specified.</param>
        public void AddTestStep(ITestStepOM testStep, TestStage stage, bool runConcurrently, bool failOnError)
        {
            ArgumentValidation.CheckForNullReference(testStep, "testStep");
            ArgumentValidation.CheckForNullReference(stage, "stage");

            AddTestStepInternal(new BizUnitTestStepWrapper(testStep, runConcurrently, failOnError), stage);
        }
Exemple #46
0
 private void AddTestStepInternal(BizUnitTestStepWrapper stepWrapper, TestStage stage)
 {
     switch (stage)
     {
         case TestStage.Setup:
             _setupSteps.Add(stepWrapper);
             break;
         case TestStage.Execution:
             _executionSteps.Add(stepWrapper);
             break;
         case TestStage.Cleanup:
             _cleanupSteps.Add(stepWrapper);
             break;
     }
 }
 /// <summary>
 /// Records a log message that indicates a named, granular test stage 
 /// has happened.
 /// </summary>
 /// <param name="message">Any message for the log.</param>
 /// <param name="name">A name for the object or event.</param>
 /// <param name="granularity">The test granularity value.</param>
 /// <param name="stage">The test stage value.</param>
 public void GranularTestStage(string message, string name, TestGranularity granularity, TestStage stage)
 {
   LogMessage m = Create(LogMessageType.TestExecution, message);
   DecorateNameProperty(m, name);
   DecorateTestGranularity(m, granularity);
   DecorateTestStage(m, stage);
   Enqueue(m);
 }
Exemple #48
0
        public static void setTestStage(TestStage stage)
        {
            if (stage == testStage)
                                return;

                        testStage = stage;

                        updateWindowStatus();
        }
Exemple #49
0
        /// <summary>
        /// Used to add a test step to a test case at a specific stage of the test.
        /// </summary>
        /// 
        /// <param name='testStep'>The test step to add to the test case, 
        /// creation of the test step is delegated to the TestStepBuilder</param>
        /// <param name='stage'>The stage of the test case in which to add the test step</param>
        public void AddTestStep(TestStepBuilder testStep, TestStage stage)
        {
            ArgumentValidation.CheckForNullReference(testStep, "testStep");

            AddTestStep(testStep, stage, false, true);
        }
 /// <summary>
 /// Decorate the log message object with a test stage value.
 /// </summary>
 /// <param name="message">The log message object.</param>
 /// <param name="stage">Test stage value.</param>
 protected static void DecorateTestStage(LogMessage message, TestStage stage)
 {
   Decorate(message, LogDecorator.TestStage, stage);
 }
Exemple #51
0
 private static void ValidateSteps(IEnumerable<TestStepBase> steps, TestStage stage, Context ctx)
 {
     // Validate test Setup Steps
     foreach (var step in steps)
     {
         Exception caughtEx = null;
         try
         {
             step.Validate(ctx);
             if(null != step.SubSteps)
             {
                 foreach (var subStep in step.SubSteps)
                 {
                     subStep.Validate(ctx);
                 }
             }
         }
         catch(Exception ex)
         {
             caughtEx = ex;
             throw;
         }
         finally
         {
             ctx.Logger.ValidateTestSteps(stage, step.GetType().ToString(), caughtEx);
         }
     }
 }
 /// <summary>
 /// Records a harness state for the unit test harness.
 /// </summary>
 /// <param name="harness">The unit test harness.</param>
 /// <param name="name">The harness name.</param>
 /// <param name="stage">The test stage.</param>
 public void UnitTestHarnessStage(UnitTestHarness harness, string name, TestStage stage)
 {
   LogMessage m = Create(LogMessageType.TestExecution, name);
   MarkUnitTestMessage(m);
   DecorateNameProperty(m, name);
   DecorateTestGranularity(m, TestGranularity.Harness);
   m[UnitTestLogDecorator.UnitTestHarness] = harness;
   DecorateTestStage(m, stage);
   Enqueue(m);
 }
Exemple #53
0
        private void ExecuteSteps(IEnumerable<BizUnitTestStepWrapper> steps, TestStage stage)
        {
            if (null == steps)
            {
                return;
            }

            foreach (BizUnitTestStepWrapper step in steps)
            {
                ExecuteTestStep(step, stage);
            }

            FlushConcurrentQueue(true, stage);
        }
 /// <summary>
 /// Log a test method's stage.
 /// </summary>
 /// <param name="method">The test method metadata object.</param>
 /// <param name="stage">The test stage.</param>
 public void TestMethodStage(ITestMethod method, TestStage stage)
 {
   TestGranularity granularity = TestGranularity.TestScenario;
   LogMessage m = Create(LogMessageType.TestExecution, method.Name);
   MarkUnitTestMessage(m);
   DecorateNameProperty(m, method.Name);
   DecorateTestGranularity(m, granularity);
   m[UnitTestLogDecorator.TestMethodMetadata] = method;
   DecorateTestStage(m, stage);
   Enqueue(m);
 }
Exemple #55
0
        private void ExecuteTestStep(BizUnitTestStepWrapper stepWrapper, TestStage stage)
        {
            try
            {
                // Should this step be executed concurrently?
                if (stepWrapper.RunConcurrently)
                {
                    _logger.TestStepStart(stepWrapper.TypeName, DateTime.Now, true, stepWrapper.FailOnError);
                    Interlocked.Increment(ref _inflightQueueDepth);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(WorkerThreadThunk), new ConcurrentTestStepWrapper(stepWrapper, _context));
                }
                else
                {
                    _logger.TestStepStart(stepWrapper.TypeName, DateTime.Now, false, stepWrapper.FailOnError);
                    stepWrapper.Execute(_context);
                }
            }
            catch (Exception e)
            {
                _logger.TestStepEnd(stepWrapper.TypeName, DateTime.Now, e);

                if (stepWrapper.FailOnError)
                {
                    if (e is ValidationStepExecutionException)
                    {
                        throw;
                    }
                    else
                    {
                        var tsee = new TestStepExecutionException("BizUnit encountered an error executing a test step", e, stage, _testName, stepWrapper.TypeName);
                        throw tsee;
                    }
                }
            }

            if (!stepWrapper.RunConcurrently)
            {
                _logger.TestStepEnd(stepWrapper.TypeName, DateTime.Now, null);
            }

            FlushConcurrentQueue(false, stage);
        }