Esempio n. 1
0
        public void CanCreateUpdateDeleteSourceControl()
        {
            using (var context = MockContext.Start(GetType().FullName))
            {
                using (var testFixture = new AutomationTestBase(context))
                {
                    var sourceControlName = SourceControlDefinition.TestSimpleSourceControlDefinition.SourceControlName;
                    var repoUrl           = SourceControlDefinition.TestSimpleSourceControlDefinition.RepoUrl;
                    var branch            = SourceControlDefinition.TestSimpleSourceControlDefinition.Branch;
                    var folderPath        = SourceControlDefinition.TestSimpleSourceControlDefinition.FolderPath;
                    var autoSync          = SourceControlDefinition.TestSimpleSourceControlDefinition.AutoSync;
                    var publishRunbook    = SourceControlDefinition.TestSimpleSourceControlDefinition.PublishRunbook;
                    var sourceType        = SourceControlDefinition.TestSimpleSourceControlDefinition.SourceType;
                    var accessToken       = SourceControlDefinition.TestSimpleSourceControlDefinition.AccessToken;
                    var description       = SourceControlDefinition.TestSimpleSourceControlDefinition.Description;
                    var updateBranchName  = SourceControlDefinition.TestSimpleSourceControlDefinition.UpdateBranchName;
                    var updateAutoPublish = SourceControlDefinition.TestSimpleSourceControlDefinition.UpdateAutoPublish;

                    var sourceControl =
                        testFixture.CreateSourceControl(sourceControlName, repoUrl, branch, folderPath, autoSync, publishRunbook,
                                                        sourceType, accessToken, description);

                    var retrievedSourceControl = testFixture.GetSourceControl(sourceControlName);

                    Assert.NotNull(retrievedSourceControl);
                    Assert.Equal(retrievedSourceControl.RepoUrl, sourceControl.RepoUrl);
                    Assert.Equal(retrievedSourceControl.Branch, sourceControl.Branch);
                    Assert.Equal(retrievedSourceControl.FolderPath, sourceControl.FolderPath);
                    Assert.Equal(retrievedSourceControl.AutoSync, sourceControl.AutoSync);
                    Assert.Equal(retrievedSourceControl.PublishRunbook, sourceControl.PublishRunbook);
                    Assert.Equal(retrievedSourceControl.SourceType, sourceControl.SourceType);
                    Assert.Equal(retrievedSourceControl.Description, sourceControl.Description);

                    var updatedSourceControl =
                        testFixture.UpdateSourceControl(sourceControlName, updateBranchName, updateAutoPublish);

                    Assert.NotNull(updatedSourceControl);
                    Assert.Equal(updatedSourceControl.Branch, updateBranchName);
                    Assert.Equal(updatedSourceControl.AutoSync, updateAutoPublish);

                    var sourceControlList = testFixture.GetSourceControls();

                    Assert.NotNull(sourceControlList);
                    Assert.Single(sourceControlList.ToList());
                    sourceControl = sourceControlList.ToList()[0];
                    Assert.Equal(sourceControlName, sourceControl.Name);

                    testFixture.DeleteSourceControl(sourceControlName);

                    Assert.Throws <ErrorResponseException>(() =>
                    {
                        sourceControl = testFixture.GetSourceControl(sourceControlName);
                    });
                }
            }
        }