Beispiel #1
0
        public void TestReportModelTestDispatcherNullOnWordCallsNoExeptions()
        {
            //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 myWordRibonMock            = new Mock <IWordRibbon>();
            var myProgressCancellationMock = new Mock <ITestReportingProgressCancellationService>();

            var testReportModelMock = new TestSpecificationReportModel(mySyncServiceDocModelMock.Object, new ViewDispatcher(null), myTfsTestAdapterMock.Object, myWordRibonMock.Object, myProgressCancellationMock.Object);

            try
            {
                var myTestConfiguration = new Mock <ITfsTestConfiguration>();
                testReportModelMock.SelectedTestConfiguration = myTestConfiguration.Object;
                var plans = testReportModelMock.TestPlans;
                Assert.IsNull(plans);
                testReportModelMock.SelectedTestPlan = myTfsTestPlan.Object;
            }
            catch (NullReferenceException)
            {
                Assert.Fail("Dispatcher is null and must not be called.");
            }
        }
        /// <summary>
        /// This method creates a word document with the TestSpecificationReport-Command
        /// </summary>
        public void CreateTestSpecDocument(DocumentConfiguration documentConfiguration)
        {
            try
            {
                SyncServiceTrace.D(Resources.CreateTestSpecificationDoc);
                _documentConfiguration = documentConfiguration;
                Initialize();
                var testSpecSettings = _documentConfiguration.TestSpecSettings;
                var testAdapter      = SyncServiceFactory.CreateTfsTestAdapter(_documentModel.TfsServer, _documentModel.TfsProject, _documentModel.Configuration);
                TestCaseSortType testCaseSortType;
                Enum.TryParse(testSpecSettings.SortTestCasesBy, out testCaseSortType);
                DocumentStructureType documentStructure;
                Enum.TryParse(testSpecSettings.DocumentStructure, out documentStructure);
                ITfsTestPlan testPlan = testAdapter.GetTestPlans(null).Where(plan => plan.Name == testSpecSettings.TestPlan).FirstOrDefault();
                if (testPlan == null)
                {
                    SyncServiceTrace.D(Resources.TestSettingsInvalidTestPlan);
                    throw new ArgumentException(Resources.TestSettingsInvalidTestPlan);
                }

                var testSuiteSearcher = new TestSuiteSearcher(testPlan);
                var testSuite         = testSuiteSearcher.SearchTestSuiteWithinTestPlan(testSpecSettings.TestSuite);

                var reportModel = new TestSpecificationReportModel(_documentModel,
                                                                   testAdapter,
                                                                   testPlan,
                                                                   testSuite,
                                                                   testSpecSettings.CreateDocumentStructure,
                                                                   testSpecSettings.SkipLevels,
                                                                   documentStructure,
                                                                   testCaseSortType,
                                                                   new TestReportingProgressCancellationService(false));
                reportModel.CreateReport();

                FinalizeDocument();
            }
            catch (Exception e)
            {
                if (_wordApplication != null)
                {
                    _wordApplication.Quit();
                }
                // ReSharper disable once PossibleIntendedRethrow
                throw e;
            }
        }
Beispiel #3
0
        public void TestSpecReportModelCreatingViaCmdGivesNoExeptions()
        {
            //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 myProgressCancellationMock = new Mock <ITestReportingProgressCancellationService>();


            var testReportModelMock = new TestSpecificationReportModel(mySyncServiceDocModelMock.Object, myTfsTestAdapterMock.Object, myTfsTestPlan.Object, null, true, 0, DocumentStructureType.TestPlanHierarchy, TestCaseSortType.IterationPath, myProgressCancellationMock.Object);

            Assert.IsNotNull(testReportModelMock);
            Assert.IsNotNull(testReportModelMock.SelectedTestPlan);
        }