Exemple #1
0
        public void Setup()
        {
            _createGitLabGroupCommand      = A.Fake <ICreateGitLabGroupCommand>();
            _createGitLabProjectCommand    = A.Fake <ICreateGitLabProjectCommand>();
            _pushToGitLabRepositoryCommand = A.Fake <IPushToGitLabRepositoryCommand>();
            _gitLabProjectFactory          = A.Fake <IGitLabProjectFactory>();
            _gitLabGroupFactory            = A.Fake <IGitLabGroupFactory>();

            _pushToRepositoryResponse = new PushToRepositoryResponse()
            {
                Successful = true
            };

            _group               = new Group();
            _project             = new Project();
            _createSolutionModel = new CreateSolutionModel();

            A.CallTo(() => _pushToGitLabRepositoryCommand.ExecuteAsync(A <PushToRepositoryRequest> ._))
            .Returns(_pushToRepositoryResponse);

            A.CallTo(() => _createGitLabGroupCommand.ExecuteAsync(A <Group> ._)).Returns(_group);
            A.CallTo(() => _createGitLabProjectCommand.ExecuteAsync(A <Project> ._)).Returns(_project);

            _sut = new CreateGitLabSolutionCommand(_createGitLabGroupCommand, _createGitLabProjectCommand,
                                                   _pushToGitLabRepositoryCommand, _gitLabProjectFactory, _gitLabGroupFactory);
        }
        public async Task <CreateGitLabSolutionResponse> ExecuteAsync(CreateSolutionModel model,
                                                                      Action <CreateSolutionModel, string> notifyAction)
        {
            var group    = _gitLabGroupFactory.Create(model.GitLabProjectName, model.GitLabGroupPath);
            var newGroup = await _createGitLabGroupCommand.ExecuteAsync(group);

            var project = _gitLabProjectFactory.Create(model.GitLabProjectName, model.GitLabProjectDescription, newGroup.Id);

            project = await _createGitLabProjectCommand.ExecuteAsync(project);

            var pushRequest = new PushToRepositoryRequest()
            {
                RepositoryUrl = project.HttpUrl
            };
            var repoResponse = await _pushToGitLabRepositoryCommand.ExecuteAsync(pushRequest);

            return(new CreateGitLabSolutionResponse()
            {
                Group = newGroup,
                Project = project,
                PushToRepositorySuccessful = repoResponse.Successful
            });
        }