Esempio n. 1
0
        /// <summary>
        /// Builds the test model.
        /// </summary>
        /// <param name="repository">The MbUnitCpp unmanaged test repository.</param>
        /// <param name="progressMonitor">The active progress monitor for the task.</param>
        protected void BuildTestModel(UnmanagedTestRepository repository, IProgressMonitor progressMonitor)
        {
            Test fixture = null;
            Test group = null;
            var root = repository.CreateRootTest();
            TestModel.RootTest.AddChild(root);

            foreach (var testInfoData in repository.GetTests())
            {
                if (progressMonitor.IsCanceled)
                    return;

                var test = new MbUnitCppTest(testInfoData, repository);

                switch (testInfoData.Kind)
                {
                    case NativeTestKind.Fixture:
                        fixture = test;
                        root.AddChild(fixture);
                        break;
                
                    case NativeTestKind.Test:
                        fixture.AddChild(test);
                        break;

                    case NativeTestKind.Group:
                        group = test;
                        fixture.AddChild(group);
                        break;

                    case NativeTestKind.RowTest:
                        test.Name = group.Name + ((test.Name.Length > 0) ? String.Format(" ({0})", test.Name) : String.Empty);
                        group.AddChild(test);
                        break;
             
                    default:
                        throw new ModelException(String.Format("Unexpected or invalid MbUnitCpp test kind '{0}'.", testInfoData.Kind));
                }
            }

            TestModelSerializer.PublishTestModel(TestModel, MessageSink);
        }