public ServiceTests() { //Configure db var optionsBuilder = new DbContextOptionsBuilder <GithubReposContext>() .UseInMemoryDatabase("githubReposTestDB"); var _dbContext = new GithubReposContext(optionsBuilder.Options); //Mock octokit ReadOnlyCollection <Repository> mockedRepos = new ReadOnlyCollection <Repository>(GetRepos()); var response = new SearchRepositoryResult(ListSize, false, mockedRepos); var mockedClient = new Mock <IGitHubClient>(); mockedClient.Setup(githubService => githubService.Search.SearchRepo(It.IsAny <SearchRepositoriesRequest>())) .Returns(Task.Factory.StartNew(() => response)); //Mount service _service = new GithubService(_dbContext, mockedClient.Object); }
public HomeController(GithubReposContext context) { var githubClient = new GitHubClient(new ProductHeaderValue(Environment.GetEnvironmentVariable("API_ID"))); _service = new GithubService(context, githubClient); }
public GithubService(GithubReposContext context, IGitHubClient gitHubClient) { _repository = new GithubRepository(context); _github = gitHubClient; }
public GithubRepository(GithubReposContext context) { _context = context; }