public Result <ListMergesParameters> NegotiateListMergeRequestsParameters(ListMergesOptions options, string defaultProject) { var project = GetProject(options, defaultProject); if (project.IsFailure) { return(Fail <ListMergesParameters>(project)); } var state = ParseMergeRequestState(options.State); if (!state.HasValue) { return(Fail <ListMergesParameters>($"State parameter: {options.State} is not supported." + "Supported values are: opened|closed|merged")); } return(Ok(new ListMergesParameters( project.Value, state.Value, options.Assignee) { AssignedToCurrentUser = options.AssignedToMe })); }
public void NegotiateListMergeRequestParametersReturnsFailureForUnknownState( ListMergesOptions options, string defaultProject, string unknownState) { options.State = unknownState; var sut = new MergeRequestsParametersNegotiator(); sut.NegotiateListMergeRequestsParameters(options, defaultProject).IsFailure.Should().BeTrue(); }
public void NegotiateListMergeRequestParametersCreatesParametersFromOptions(ListMergesOptions options, string defaultProject) { options.State = "opened"; var sut = new MergeRequestsParametersNegotiator(); sut.NegotiateListMergeRequestsParameters(options, defaultProject).Value.Should().Match <ListMergesParameters>(o => o.State == MergeRequestState.Opened && o.Assignee == options.Assignee && o.AssignedToCurrentUser == options.AssignedToMe && o.Project == options.Project); }
public async Task Visit(ListMergesOptions options) { if (!ValidateConfiguration()) { return; } var parameters = _parametersHandler.NegotiateListMergesParameters(options); if (parameters.IsSuccess) { await _mergesHandler.ListMerges(parameters.Value); } else { ShowError(parameters); } }
public Result <ListMergesParameters> NegotiateListMergesParameters(ListMergesOptions options) { return(_mergesParametersNegotiator.NegotiateListMergeRequestsParameters(options, _appSettings.DefaultProject)); }