Exemplo n.º 1
0
        public void TestResultReportModelCreatingViaCmdGivesNoExeptions()
        {
            //new Sync
            var mySyncServiceDocModelMock = GetISyncServiceMockWithDefault();
            var myTfsTestAdapterMock      = new Mock <ITfsTestAdapter>();
            var myTfsTestPlan             = new Mock <ITfsTestPlan>();

            myTfsTestPlan.SetupGet(g => g.Name).Returns("Plan1");

            var tempList = new List <ITfsTestPlan> {
                myTfsTestPlan.Object
            };

            myTfsTestAdapterMock.Setup(g => g.AvailableTestPlans).Returns(tempList);
            var myTfsServerBuild = new Mock <ITfsServerBuild>();

            myTfsServerBuild.SetupGet(g => g.Name).Returns("All");
            myTfsServerBuild.SetupGet(g => g.BuildNumber).Returns(string.Empty);
            myTfsTestAdapterMock.Setup(g => g.GetAvailableServerBuilds()).Returns(new List <ITfsServerBuild> {
                myTfsServerBuild.Object
            });
            myTfsTestAdapterMock.Setup(x => x.GetTestConfigurationsForTestPlanWithTestResults(myTfsServerBuild.Object, myTfsTestPlan.Object)).Returns(new List <ITfsTestConfiguration>());
            var myProgressCancellationMock = new Mock <ITestReportingProgressCancellationService>();

            var testReportModelMock = new TestResultReportModel(mySyncServiceDocModelMock.Object, myTfsTestAdapterMock.Object, myTfsTestPlan.Object, null, false, 0,
                                                                DocumentStructureType.TestPlanHierarchy, TestCaseSortType.IterationPath, false, ConfigurationPositionType.AboveTestPlan, false, false, string.Empty, null, myProgressCancellationMock.Object);

            Assert.IsNotNull(testReportModelMock);
            Assert.IsNotNull(testReportModelMock.SelectedTestPlan);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method creates a word document with the TestResultReport-Command
        /// </summary>
        public void CreateTestResultDocument(DocumentConfiguration documentConfiguration)
        {
            try
            {
                SyncServiceTrace.D(Resources.CreateTestResultDoc);
                _documentConfiguration = documentConfiguration;
                Initialize();
                var testResultSettings = _documentConfiguration.TestResultSettings;
                var testAdapter        = SyncServiceFactory.CreateTfsTestAdapter(_documentModel.TfsServer, _documentModel.TfsProject, _documentModel.Configuration);
                TestCaseSortType testCaseSortType;
                Enum.TryParse(testResultSettings.SortTestCasesBy, out testCaseSortType);
                DocumentStructureType documentStructure;
                Enum.TryParse(testResultSettings.DocumentStructure, out documentStructure);
                ConfigurationPositionType configurationPositionType;
                Enum.TryParse(testResultSettings.TestConfigurationsPosition, out configurationPositionType);
                var testPlan = testAdapter.GetTestPlans(null).Where(plan => plan.Name == testResultSettings.TestPlan).FirstOrDefault();
                if (testPlan == null)
                {
                    SyncServiceTrace.D(Resources.TestSettingsInvalidTestPlan);
                    throw new ArgumentException(Resources.TestSettingsInvalidTestPlan);
                }
                var testSuiteSearcher = new TestSuiteSearcher(testPlan);
                var testSuite         = testSuiteSearcher.SearchTestSuiteWithinTestPlan(testResultSettings.TestSuite);

                var reportModel = new TestResultReportModel(_documentModel,
                                                            testAdapter,
                                                            testPlan,
                                                            testSuite,
                                                            testResultSettings.CreateDocumentStructure,
                                                            testResultSettings.SkipLevels,
                                                            documentStructure,
                                                            testCaseSortType,
                                                            testResultSettings.IncludeTestConfigurations,
                                                            configurationPositionType,
                                                            testResultSettings.IncludeOnlyMostRecentResults,
                                                            testResultSettings.MostRecentForAllConfigurations,
                                                            testResultSettings.Build,
                                                            testResultSettings.TestConfiguration,
                                                            new TestReportingProgressCancellationService(false));

                reportModel.CreateReport();
                FinalizeDocument();
            }
            catch
            {
                if (_wordApplication != null)
                {
                    _wordApplication.Quit();
                }
                // ReSharper disable once PossibleIntendedRethrow
                throw;
            }
        }