public async Task CanGetWorkflowId() { // setup _httpTest.RespondWithJson(new WorkflowResponse { TotalCount = 2, Workflows = new[] { new WorkflowResponse.Workflow { Id = 1, Name = "alpha" }, new WorkflowResponse.Workflow { Id = 2, Name = "build" } } }); // test var sut = new GithubApiService(_settings, _githubActionService); var id = await sut.GetWorkflowId(); // assertions _httpTest.ShouldHaveCalled($"https://api.github.com/repos/{_settings.Project}/actions/workflows") .WithVerb(HttpMethod.Get) .WithHeader("Authorization", $"token {_settings.Token}") .WithHeader("User-Agent", "Flurl"); id.Should().Be(2); }
public AppViewModel(INavigationService navigateService, GithubApiService ghservice, INotificationController notController, ICacheManager cache) { NavigationService = navigateService; GHService = ghservice; NotificationController = notController; //Autologin can be implemented here NavigationService.Navigate(AppPages.LoginPage); }
public LoginViewModel(INavigationService navigateService, GithubApiService ghservice, INotificationController notController, ICacheManager cache) { IsLogin = false; NavigationService = navigateService; GHService = ghservice; NotificationController = notController; _cache = cache; _loginCommand = new DelegateCommand(() => { NotificationController.SplashScreen.IsVisible = true; cache.Add("username", User); cache.Add("password", Password); GHService.UseCredentials(User, Password); NavigationService.Navigate(AppPages.MainPage); }); }
public async Task CanGetWorkflowStatus() { // setup _httpTest.RespondWithJson(new WorkflowRunsResponse { TotalCount = 2, WorkflowRuns = new[] { new WorkflowRunsResponse.WorkflowRun { Id = 2, Status = "completed", Conclusion = "success" }, new WorkflowRunsResponse.WorkflowRun { Id = 1, Status = "completed", Conclusion = "failed" } } }); // test var sut = new GithubApiService(_settings, _githubActionService); var status = await sut.GetWorkflowStatus(1); // assertions _httpTest.ShouldHaveCalled($"https://api.github.com/repos/{_settings.Project}/actions/workflows/1/runs") .WithVerb(HttpMethod.Get) .WithHeader("Authorization", $"token {_settings.Token}") .WithHeader("User-Agent", "Flurl") .WithQueryParamValue("branch", _settings.Branch) .WithQueryParamValue("page", "1") .WithQueryParamValue("per_page", "10"); status.Should().Be("success"); _writeLine.Verify(x => x(It.Is <string>(m => m == "::debug::Workflow Runs Found: 2")), Times.Once); }
public MainViewModel(INavigationService navigationService, GithubApiService ghSvc, INotificationController notController, OctocatsService octocatSvc, ICacheManager cache) { NotificationController = notController; GHService = ghSvc; OctocatService = octocatSvc; _settings = cache; this.NewsItems = new ObservableCollection <ItemViewModel>(); /* User.Subscribe(user => * { * user.Organizations.ForEach(org => GHService.GetReposForOrganization(org, RepositItems)); * }); * * RepositItems = new ObservableCollection<ItemViewModel>(); * GHService.GetUserRepos(RepositItems); * * IssuesItems = new ObservableCollection<ItemViewModel>(); * GHService.GetIssues(IssuesItems); * * _navigationService = navigationService;*/ }
public GithubController(GithubApiService githubApiService, RepositoryContext repositoryContext, IMapper mapper) { _githubApiService = githubApiService; _repositoryContext = repositoryContext; _mapper = mapper; }