コード例 #1
0
ファイル: GithubTests.cs プロジェクト: Gabee01/git-test
        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);
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: Gabee01/git-test
        public HomeController(GithubReposContext context)
        {
            var githubClient = new GitHubClient(new ProductHeaderValue(Environment.GetEnvironmentVariable("API_ID")));

            _service = new GithubService(context, githubClient);
        }
コード例 #3
0
 public GithubService(GithubReposContext context, IGitHubClient gitHubClient)
 {
     _repository = new GithubRepository(context);
     _github     = gitHubClient;
 }
コード例 #4
0
ファイル: GithubRepository.cs プロジェクト: Gabee01/git-test
 public GithubRepository(GithubReposContext context)
 {
     _context = context;
 }