示例#1
0
        public void MyTestInitialize()
        {
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");
            var serverConfiguration = CommonConfiguration.TfsTestServerConfiguration(_testContext);

            _testAdapter = SyncServiceFactory.CreateTfsTestAdapter(serverConfiguration.TeamProjectCollectionUrl, serverConfiguration.TeamProjectName, config);
        }
示例#2
0
        public static void ClassInitialize(TestContext testContext)
        {
            AIT.TFS.SyncService.Service.AssemblyInit.Instance.Init();
            AIT.TFS.SyncService.Adapter.TFS2012.AssemblyInit.Instance.Init();
            var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(CommonConfiguration.Tfs2013ServerConfiguration(testContext).ServerName, true, false);

            testManagement = projectCollection.GetService <ITestManagementService>().GetTeamProject(CommonConfiguration.Tfs2013ServerConfiguration(testContext).ProjectName);
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");

            testAdapter = SyncServiceFactory.CreateTfsTestAdapter(CommonConfiguration.Tfs2013ServerConfiguration(testContext).ServerName, CommonConfiguration.Tfs2013ServerConfiguration(testContext).ProjectName, config);
        }
        public void SynchronizedWorkItemViewModel_SynchronizationState_ShouldBeNotImported()
        {
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");

            OpenAdapters(CommonConfiguration.TfsTestServerConfiguration(_testContext), config);

            _synchronizedWorkItemViewModel = new SynchronizedWorkItemViewModel(_tfsAdapter.WorkItems.First(), null, _wordAdapter, _documentModel.Object, null);
            _synchronizedWorkItemViewModel.Refresh();

            Assert.AreEqual(SynchronizationState.NotImported, _synchronizedWorkItemViewModel.SynchronizationState);
        }
        public void SynchronizedWorkItemViewModel_SynchronizationState_ShouldBeNew()
        {
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");

            OpenAdapters(CommonConfiguration.TfsTestServerConfiguration(_testContext), config);
            _wordAdapter.CreateNewWorkItem(config.GetConfigurationItems().First());
            _wordAdapter.WorkItems.First().Fields["System.Title"].Value = "Was anderes";
            _wordAdapter = new Word2007TableSyncAdapter(_document, config);
            _wordAdapter.Open(null);

            _synchronizedWorkItemViewModel = new SynchronizedWorkItemViewModel(null, _wordAdapter.WorkItems.First(), _wordAdapter, _documentModel.Object, null);
            _synchronizedWorkItemViewModel.Refresh();
            Assert.AreEqual(SynchronizationState.New, _synchronizedWorkItemViewModel.SynchronizationState);
        }
        public void BehaviorOfWordSyncAdapterWithUnknownFieldValues()
        {
            const string hierarachyLevel0TemplateName = "HierarchieTemplateLevel0";
            const string hierarachyLevel1TemplateName = "HierarchieTemplateLevel1";

            //Create Configuration
            IConfiguration conf = CommonConfiguration.Configuration;
            var            featureBaseConfiguration             = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title").GetConfigurationItems().Single();
            var            featureHierarchieLevel0Configuration = CommonConfiguration.GetWorkItemSubtypeConfiguration(hierarachyLevel0TemplateName, "Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title", "HierarchyLevel", "0").GetConfigurationItems().Single();
            var            featureHierarchieLevel1Configuration = CommonConfiguration.GetWorkItemSubtypeConfiguration(hierarachyLevel1TemplateName, "Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title", "HierarchyLevel", "1").GetConfigurationItems().Single();

            conf.GetConfigurationItems().Add(featureBaseConfiguration);
            conf.GetConfigurationItems().Add(featureHierarchieLevel0Configuration);
            conf.GetConfigurationItems().Add(featureHierarchieLevel1Configuration);

            var range = _testDocument.ActiveWindow.Document.Range();

            _testDocument.Tables.Add(range, 4, 1);
            _testDocument.Tables[1].Cell(1, 1).Range.Text = "1Header";
            range.InsertParagraphAfter();
            range.Collapse(WdCollapseDirection.wdCollapseEnd);

            _testDocument.Tables.Add(range, 4, 1);
            _testDocument.Tables[2].Cell(1, 1).Range.Text = "2Header";
            range = _testDocument.ActiveWindow.Document.Range();
            range.Collapse(WdCollapseDirection.wdCollapseEnd);
            range.InsertParagraphAfter();
            range.Collapse(WdCollapseDirection.wdCollapseEnd);

            _testDocument.Tables.Add(range, 5, 5);
            _testDocument.Tables[3].Cell(1, 1).Range.Text = "Requirement";


            // Open the adapter with the configuration that contains the "HierarchyLevel"
            var target = CreateWord2007SyncAdapterWithConfiguration(conf);

            //Open the adapter
            Assert.IsTrue(target.Open(null));

            // test is only useful if prerequisites are met
            Assert.AreNotEqual(Direction.SetInNewTfsWorkItem, CommonConfiguration.Header1.Fields.First(x => x.Name == "System.AreaPath").Direction);
            Assert.AreEqual(Direction.SetInNewTfsWorkItem, CommonConfiguration.Header2.Fields.First(x => x.Name == "System.AreaPath").Direction);

            Assert.AreEqual(Direction.SetInNewTfsWorkItem, target.WorkItems.First().Fields["System.AreaPath"].Configuration.Direction);
            Assert.IsTrue(target.WorkItems.First().Fields.Contains("System.GibtsNicht"));
            Assert.IsTrue(target.WorkItems.First().Fields.Contains("System.IterationPath")); // inherited from level 1 header
        }
        public void SynchronizedWorkItemViewModel_SynchronizationState_ShouldBeDivergedWithConflicts()
        {
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");

            config.GetConfigurationItems().First().FieldConfigurations.Add(new ConfigurationFieldItem("System.AreaPath", "", FieldValueType.PlainText, Direction.OtherToTfs, 5, 1, "", false, HandleAsDocumentType.OleOnDemand, null, null, null, ShapeOnlyWorkaroundMode.AddSpace, null, null, null));

            OpenAdapters(CommonConfiguration.TfsTestServerConfiguration(_testContext), config);
            var tfsItem   = _tfsAdapter.WorkItems.First();
            var oldFields = tfsItem.GetWorkItemByRevision(tfsItem.Revision - 1);

            Assert.AreNotEqual(tfsItem.Fields["System.AreaPath"].Value, oldFields["System.AreaPath"].Value);

            _wordAdapter.CreateNewWorkItem(config.GetConfigurationItems().First());
            _wordAdapter.WorkItems.First().Fields["System.Title"].Value    = "Test";
            _wordAdapter.WorkItems.First().Fields["System.Id"].Value       = oldFields["System.Id"].Value;
            _wordAdapter.WorkItems.First().Fields["System.Rev"].Value      = oldFields["System.Rev"].Value;
            _wordAdapter.WorkItems.First().Fields["System.AreaPath"].Value = oldFields["System.AreaPath"].Value;
            _wordAdapter = new Word2007TableSyncAdapter(_document, config);
            _wordAdapter.Open(null);

            _synchronizedWorkItemViewModel = new SynchronizedWorkItemViewModel(_tfsAdapter.WorkItems.First(), null, _wordAdapter, _documentModel.Object, null);
            _synchronizedWorkItemViewModel.Refresh();
            Assert.AreEqual(SynchronizationState.DivergedWithConflicts, _synchronizedWorkItemViewModel.SynchronizationState);
        }
        public void SynchronizedWorkItemViewModel_SynchronizationState_ShouldBeUpToDate_WithStackRankSetToTrue()
        {
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");

            OpenAdapters(CommonConfiguration.TfsTestServerConfiguration(_testContext), config);
            config.UseStackRank = true;

            //add the stack rank configuration and a value
            _tfsAdapter.WorkItems.First().Configuration.FieldConfigurations.Add(new ConfigurationFieldItem("Microsoft.VSTS.Common.StackRank", string.Empty, FieldValueType.PlainText, Direction.OtherToTfs, 0, 0, string.Empty, false, HandleAsDocumentType.All, null, string.Empty, null, ShapeOnlyWorkaroundMode.AddSpace, false, null, null, null));
            _tfsAdapter.WorkItems.First().Fields["Microsoft.VSTS.Common.StackRank"].Value = "3000";

            _wordAdapter.CreateNewWorkItem(config.GetConfigurationItems().First());
            _wordAdapter.WorkItems.First().Fields["System.Title"].Value = _tfsAdapter.WorkItems.First().Fields["System.Title"].Value;
            _wordAdapter.WorkItems.First().Fields["System.Id"].Value = _tfsAdapter.WorkItems.First().Fields["System.Id"].Value;
            _wordAdapter.WorkItems.First().Fields["System.Rev"].Value = _tfsAdapter.WorkItems.First().Fields["System.Rev"].Value;
            _wordAdapter.WorkItems.First().Configuration.FieldConfigurations.Add(new ConfigurationFieldItem("Microsoft.VSTS.Common.StackRank", string.Empty, FieldValueType.PlainText, Direction.OtherToTfs, 0, 0, string.Empty, false, HandleAsDocumentType.All, null, string.Empty, null, ShapeOnlyWorkaroundMode.AddSpace, false, null, null, null));

            _wordAdapter = new Word2007TableSyncAdapter(_document, config);
            _wordAdapter.Open(null);

            _synchronizedWorkItemViewModel = new SynchronizedWorkItemViewModel(_tfsAdapter.WorkItems.First(), null, _wordAdapter, _documentModel.Object, null);
            _synchronizedWorkItemViewModel.Refresh();
            Assert.AreEqual(SynchronizationState.UpToDate, _synchronizedWorkItemViewModel.SynchronizationState);
        }
示例#8
0
        public static void MyClassInitialize(TestContext testContext)
        {
            _testContext = testContext;

            AIT.TFS.SyncService.Service.AssemblyInit.Instance.Init();
            AIT.TFS.SyncService.Adapter.TFS2012.AssemblyInit.Instance.Init();

            var serverConfig = CommonConfiguration.TfsTestServerConfiguration(_testContext);

            CommonConfiguration.ReplaceConfigFileTokens(_testContext);
            var config = CommonConfiguration.GetSimpleFieldConfiguration("Requirement", Direction.OtherToTfs, FieldValueType.PlainText, "System.Title");

            _testAdapter = SyncServiceFactory.CreateTfsTestAdapter(serverConfig.TeamProjectCollectionUrl, serverConfig.TeamProjectName, config);
            var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri(serverConfig.TeamProjectCollectionUrl));

            _testManagement = projectCollection.GetService <ITestManagementService>().GetTeamProject(serverConfig.TeamProjectName);

            var sharedSteps = _testManagement.SharedSteps.Query("SELECT * FROM WorkItems WHERE System.Title='UnitTest_SharedStep'");

            _sharedStep = sharedSteps.FirstOrDefault();

            if (_sharedStep == null)
            {
                _sharedStep = _testManagement.SharedSteps.Create();
                var sharedStep1 = _sharedStep.CreateTestStep();
                sharedStep1.Title          = "First Shared Step";
                sharedStep1.ExpectedResult = "Result of first shared step";

                var sharedStep2 = _sharedStep.CreateTestStep();
                sharedStep2.Title          = "Second Shared Step .: @ParametersDontLikeSpecialChars";
                sharedStep2.ExpectedResult = "Result of second shared step";

                _sharedStep.Actions.Add(sharedStep1);
                _sharedStep.Actions.Add(sharedStep2);

                _sharedStep.Title = "UnitTest_SharedStep_1";
                _sharedStep.Save();
            }
            else
            {
                var sharedStep1 = _sharedStep.Actions[0] as ITestStep;
                if (sharedStep1 != null)
                {
                    sharedStep1.Title          = "First Shared Step";
                    sharedStep1.ExpectedResult = "Result of first shared step";
                }

                var sharedStep2 = _sharedStep.Actions[1] as ITestStep;
                if (sharedStep2 != null)
                {
                    sharedStep2.Title          = "Second Shared Step .: @ParametersDontLikeSpecialChars";
                    sharedStep2.ExpectedResult = "Result of second shared step";
                }

                _sharedStep.WorkItem.Open();
                _sharedStep.Save();
            }

            var testCases = _testManagement.TestCases.Query("SELECT * FROM WorkItems WHERE System.Title='UnitTest_TestCase'");

            _testCase = testCases.FirstOrDefault();

            if (_testCase == null)
            {
                _testCase       = _testManagement.TestCases.Create();
                _testCase.Title = "UnitTest_TestCase";

                var step1 = _testCase.CreateTestStep();
                step1.Title          = "First Step";
                step1.ExpectedResult = "Result of first step";

                var step2 = _testCase.CreateTestStep();
                step2.Title          = "Second Step";
                step2.ExpectedResult = "Result of second step";

                var step3 = _testCase.CreateTestStep();
                step3.Title          = "@DescriptionParameter";
                step3.ExpectedResult = "@ExpectedResultParameter";

                var ssr = _testCase.CreateSharedStepReference();
                ssr.SharedStepId = _sharedStep.Id;

                _testCase.Actions.Add(step1);
                _testCase.Actions.Add(step2);
                _testCase.Actions.Add(ssr);
                _testCase.Actions.Add(step3);
                _testCase.Save();
            }

            var testConfigurations = _testManagement.TestConfigurations.Query("Select * from TestConfiguration where Name='UnitTest_TestConfiguration'");

            _testConfiguration = testConfigurations.FirstOrDefault();

            if (_testConfiguration == null)
            {
                _testConfiguration      = _testManagement.TestConfigurations.Create();
                _testConfiguration.Name = "UnitTest_TestConfiguration";
                _testConfiguration.Save();
            }
        }