Exemplo n.º 1
0
        public void CopyFiles()
        {
            //Create the work folder
            if (Directory.Exists(".\\Work"))
            {
                Directory.Delete(".\\Work", true);
            }

            var merger = new MergeTask();

            merger.CopyFiles(".\\Work", ".\\Resources\\TestItems");
        }
Exemplo n.º 2
0
        public async void RunMainTask_NoProvider()
        {
            var config = new Dictionary <string, string>();

            var task = new MergeTask(_projectService.Object, _externalServiceService.Object, _externalServiceTypeService.Object, _providerService.Object, _taskProviderManager.Object, _logger.Object);

            task.SetConfig(config, "working");
            task.Provider = "NotExistRepositoryProvider";

            var result = await task.RunMainTask(new Dictionary <string, string>());

            Assert.False(result.IsSuccess);
            Assert.Equal("Code repository provider \"NotExistRepositoryProvider\" could not be found.", result.ErrorMessage);
        }
Exemplo n.º 3
0
        public async void RunMainTask_NoPRNumber()
        {
            var config = new Dictionary <string, string>();

            var task = new MergeTask(_projectService.Object, _externalServiceService.Object, _externalServiceTypeService.Object, _providerService.Object, _pluginManager.Object, _logger.Object);

            task.SetConfig(config, "working");
            task.Provider = "FakeCodeRepositoryProvider";

            var result = await task.RunMainTask(new Dictionary <string, string>());

            Assert.False(result.IsSuccess);
            Assert.Equal("PR Number was undefined.", result.ErrorMessage);
        }
Exemplo n.º 4
0
        public void TestMergeMissingContent()
        {
            //Create the work folder
            if (!Directory.Exists(".\\Work"))
            {
                Directory.CreateDirectory(".\\Work");
            }

            File.Copy(".\\Resources\\EmptyTargetProject.scproj", ".\\Work\\EmptyTargetProject.scproj", true);

            var merger = new MergeTask();

            merger.MergeProjects(".\\Work\\EmptyTargetProject.scproj", "x");
        }
Exemplo n.º 5
0
        public void TestUpdateExcludedAssemblies()
        {
            //Create the work folder
            if (!Directory.Exists(".\\Work"))
            {
                Directory.CreateDirectory(".\\Work");
            }

            File.Copy(".\\Resources\\ContentProject.scproj", ".\\Work\\ContentProject.scproj", true);

            var merger = new MergeTask();

            merger.UpdateExcludedFiles(".\\Work\\ContentProject.scproj");
        }
Exemplo n.º 6
0
        public async void RunMainTask_AdditionalConfigSecured()
        {
            _taskProviderManager.Setup(p => p.InvokeTaskProvider(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync((string taskProviderDll, string taskProviderArgs, string secretTaskProviderArgs) => new Dictionary <string, object>
            {
                { "remoteUrl", "http://github.com/test/test" }
            });
            _taskProviderManager.Setup(p => p.GetTaskProviders(It.IsAny <string>())).Returns(new List <TaskProviderItem>
            {
                new TaskProviderItem("FakeCodeRepositoryProvider", "path/to/FakeCodeRepositoryProvider.dll", new string[] { "GitHub" })
            });
            _externalServiceService.Setup(p => p.GetExternalServiceByName(It.IsAny <string>())).ReturnsAsync((string name) => new ExternalServiceDto
            {
                Name   = name,
                Config = new Dictionary <string, string>
                {
                    { "AuthToken", "123" }
                }
            });

            var config = new Dictionary <string, string>
            {
                { "GitHubExternalService", "github-test" }
            };

            var task = new MergeTask(_projectService.Object, _externalServiceService.Object, _externalServiceTypeService.Object, _providerService.Object, _taskProviderManager.Object, _logger.Object);

            task.SetConfig(config, "working");
            task.Provider          = "FakeCodeRepositoryProvider";
            task.AdditionalConfigs = new Dictionary <string, string>
            {
                { "ConnectionString", "Server=localhost;Database=TestProject;User ID=sa;Password=samprod;" }
            };

            var result = await task.RunMainTask(new Dictionary <string, string> {
                { "PRNumber", "1" }
            });

            Assert.True(result.IsSuccess);
            Assert.Equal("http://github.com/test/test", result.ReturnValue);
            Assert.Equal("Pull request #1 has been merged", result.TaskRemarks);

            Assert.Equal(2, task.AdditionalConfigs.Count);
            Assert.Equal(2, task.SecuredAdditionalConfigs.Count);
            Assert.Equal("***", task.SecuredAdditionalConfigs["AuthToken"]);
            Assert.Equal("***", task.SecuredAdditionalConfigs["ConnectionString"]);
            Assert.Equal("123", task.AdditionalConfigs["AuthToken"]);
            Assert.Equal("Server=localhost;Database=TestProject;User ID=sa;Password=samprod;", task.AdditionalConfigs["ConnectionString"]);
        }
Exemplo n.º 7
0
        public async void RunMainTask_Failed()
        {
            _taskProviderManager.Setup(p => p.InvokeTaskProvider(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync((string taskProviderDll, string taskProviderArgs, string secretTaskProviderArgs) => new Dictionary <string, object>
            {
                { "errorMessage", "error-message" }
            });

            var config = new Dictionary <string, string>();

            var task = new MergeTask(_projectService.Object, _externalServiceService.Object, _externalServiceTypeService.Object, _providerService.Object, _taskProviderManager.Object, _logger.Object);

            task.SetConfig(config, "working");
            task.Provider = "FakeCodeRepositoryProvider";

            var result = await task.RunMainTask(new Dictionary <string, string> {
                { "PRNumber", "1" }
            });

            Assert.False(result.IsSuccess);
            Assert.Equal("error-message", result.ErrorMessage);
        }
Exemplo n.º 8
0
        public async void RunMainTask_Success()
        {
            _taskProviderManager.Setup(p => p.InvokeTaskProvider(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync((string taskProviderDll, string taskProviderArgs, string secretTaskProviderArgs) => new Dictionary <string, object>
            {
                { "remoteUrl", "http://github.com/test/test" }
            });

            var config = new Dictionary <string, string>();

            var task = new MergeTask(_projectService.Object, _externalServiceService.Object, _externalServiceTypeService.Object, _providerService.Object, _taskProviderManager.Object, _logger.Object);

            task.SetConfig(config, "working");
            task.Provider = "FakeCodeRepositoryProvider";

            var result = await task.RunMainTask(new Dictionary <string, string> {
                { "PRNumber", "1" }
            });

            Assert.True(result.IsSuccess);
            Assert.Equal("http://github.com/test/test", result.ReturnValue);
            Assert.Equal("Pull request #1 has been merged", result.TaskRemarks);
        }
Exemplo n.º 9
0
 private void InitBlock()
 {
     merge_task = new MergeTask(this);
 }
Exemplo n.º 10
0
        public void TestMergeMissingTarget()
        {
            var merger = new MergeTask();

            merger.MergeProjects("x", "?");
        }
Exemplo n.º 11
0
        public void TestMergeNullContent()
        {
            var merger = new MergeTask();

            merger.MergeProjects("?", null);
        }
Exemplo n.º 12
0
        public void TestMergeNullTarget()
        {
            var merger = new MergeTask();

            merger.MergeProjects(null, "?");
        }
Exemplo n.º 13
0
        public void CopyFilesMissingSource()
        {
            var merger = new MergeTask();

            merger.CopyFiles("x", "x");
        }
Exemplo n.º 14
0
        public void CopyFilesNullSource()
        {
            var merger = new MergeTask();

            merger.CopyFiles("x", null);
        }
Exemplo n.º 15
0
        public void CopyFilesNullTarget()
        {
            var merger = new MergeTask();

            merger.CopyFiles(null, "x");
        }