예제 #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);
        }
예제 #2
0
        public void GetTests()
        {
            using (var repository = new UnmanagedTestRepository(resources))
            {
                Assert.IsTrue(repository.IsValid);
                TestInfoData[] items = repository.GetTests().ToArray();
                Assert.IsNotEmpty(items);

                using (TestLog.BeginSection(String.Format("Found {0} test item(s):", items.Length)))
                {
                    foreach (TestInfoData item in items)
                    {
                        DiagnosticLog.WriteLine("{0}: Fixture={1}, Test={2}, Row={3}, Kind={4}",
                                                item.Name, item.Native.Position.pTestFixture, item.Native.Position.pTest,
                                                item.Native.Position.pRow, item.Kind);
                    }
                }
            }
        }