Exemplo n.º 1
0
        /// <summary>
        /// Retrieves the <see cref="Repository"/> for the specified owner and name.
        /// </summary>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <returns>A <see cref="Repository"/></returns>
        public IObservable <Repository> Get(string owner, string name)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, nameof(owner));
            Ensure.ArgumentNotNullOrEmptyString(name, nameof(name));

            return(_client.Get(owner, name).ToObservable());
        }
        public async Task Report_SkipsIfIssuesAreNotEnabled()
        {
            var report = new ValidationReport
            {
                Owner          = "owner",
                RepositoryName = "repo",
                Results        = new ValidationResult[]
                {
                    new ValidationResult("Rule", "how to fix", false, null)
                }
            };

            _mockRepositoryClient.Get(Arg.Any <string>(), Arg.Any <string>()).Returns((args) => Task.FromResult(CreateRepository((string)args[0], (string)args[1], false, false)));
            await _reporter.Report(new ValidationReport[] { report });

            await _mockIssuesClient.DidNotReceive().Create(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <NewIssue>());
        }
Exemplo n.º 3
0
        public static async Task <bool> Exists(this IRepositoriesClient client, string owner, string name)
        {
            try
            {
                await client.Get(owner, name);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        public void Setup()
        {
            var logger = Substitute.For <ILogger <GitHubReporter> >();

            _mockClient       = Substitute.For <IGitHubClient>();
            _mockIssuesClient = Substitute.For <IIssuesClient>();
            _mockClient.Issue.Returns(_mockIssuesClient);
            _mockUsersClient = Substitute.For <IUsersClient>();
            _mockClient.User.Returns(_mockUsersClient);
            _mockRepositoryClient = Substitute.For <IRepositoriesClient>();
            _mockClient.Repository.Returns(_mockRepositoryClient);

            var user = new User(null, null, null, 0, null, DateTime.UtcNow, DateTime.UtcNow, 0, null, 0, 0, false, null, 0, 0, null, "LOGIN", null, null, 0, null, 0, 0, 0, null, new RepositoryPermissions(), false, null, null);

            _mockUsersClient.Current().Returns(Task.FromResult(user));

            _mockRepositoryClient.Get(Arg.Any <string>(), Arg.Any <string>()).Returns((args) => Task.FromResult(CreateRepository((string)args[0], (string)args[1], true, false)));

            _reporter = new GitHubReporter(logger, _mockClient, _config);
        }