Example #1
0
        public void Execute_should_throw_appropriately()
        {
            using (TestHostContext hc = CreateTestContext())
            {
                InitializeExecutionContext(hc);
                var updateRepoPath = new PluginInternalUpdateRepositoryPathCommand();
                var command        = new Microsoft.VisualStudio.Services.Agent.Command("area", "event");

                // missing alias
                Assert.Throws <Exception>(() => updateRepoPath.Execute(_ec.Object, command));

                // add alias, still missing matching repository
                command.Properties.Add("alias", "repo1");
                Assert.Throws <Exception>(() => updateRepoPath.Execute(_ec.Object, command));

                // add repository, still missing data
                _repositories.Add(new RepositoryResource()
                {
                    Alias = "repo1"
                });
                Assert.Throws <Exception>(() => updateRepoPath.Execute(_ec.Object, command));
            }
        }
Example #2
0
        public void Execute_should_set_paths_appropriately_for_self_repo_with_multiple_checkouts()
        {
            using (TestHostContext hc = CreateTestContext())
            {
                InitializeExecutionContext(hc, true);
                var updateRepoPath = new PluginInternalUpdateRepositoryPathCommand();
                var command        = new Microsoft.VisualStudio.Services.Agent.Command("area", "event");
                command.Properties.Add("alias", "self");
                command.Data = "/1/newPath";

                updateRepoPath.Execute(_ec.Object, command);

                Assert.Equal("/1/newPath", _selfRepo.Properties.Get <String>(RepositoryPropertyNames.Path));
                Assert.Equal("/1/otherRepo", _otherRepo.Properties.Get <String>(RepositoryPropertyNames.Path));
                Assert.Equal(null, _variables.Get(Constants.Variables.Build.SourcesDirectory));
                Assert.Equal("newPath", GetLastPathPart(_variables.Get(Constants.Variables.Build.RepoLocalPath)));
                Assert.Equal(null, _variables.Get(Constants.Variables.System.DefaultWorkingDirectory));
            }
        }