コード例 #1
0
        public async Task Create_TitleIsNull_ThrowArgumentNullException()
        {
            var sut = new ProjectSnippetRepository(_requestFactory);

            await Assert.ThrowsAsync <ArgumentNullException>(
                () => sut.Create(0, null, "fileName", "code", VisibilityLevel.Public));
        }
コード例 #2
0
        public async Task Update_ValidParameters_SetsCorrectResourceAndMethod()
        {
            var sut = new ProjectSnippetRepository(_requestFactory);

            await sut.Update(0, 0);

            _requestFactory.Received().Create("projects/{projectId}/snippets/{id}", Method.Put);
        }
コード例 #3
0
        public async Task Create_ValidParameters_SetsCorrectResourceAndMethod()
        {
            var sut = new ProjectSnippetRepository(_requestFactory);

            await sut.Create(0, "title", "fileName", "code", VisibilityLevel.Public);

            _requestFactory.Received().Create("projects/{projectId}/snippets", Method.Post);
        }
コード例 #4
0
        public async Task Create_ValidParameters_AddsVisibilityLevelParameter()
        {
            const VisibilityLevel expected = VisibilityLevel.Public;
            var sut = new ProjectSnippetRepository(_requestFactory);

            await sut.Create(0, "title", "fileName", "code", expected);

            _request.Received().AddParameter("visibility_level", expected);
        }
コード例 #5
0
        public async Task Create_ValidParameters_AddsTitleParameter()
        {
            const string expected = "title";
            var          sut      = new ProjectSnippetRepository(_requestFactory);

            await sut.Create(0, expected, "fileName", "code", VisibilityLevel.Public);

            _request.Received().AddParameter("title", expected);
        }
コード例 #6
0
        public async Task Create_ValidParameters_AddsProjectIdUrlSegment()
        {
            const uint expected = 0;
            var        sut      = new ProjectSnippetRepository(_requestFactory);

            await sut.Create(expected, "title", "fileName", "code", VisibilityLevel.Public);

            _request.Received().AddUrlSegment("projectId", expected);
        }
コード例 #7
0
        public async Task Update_VisibilityLevelIsSet_AddsVisibilityLevelParameter()
        {
            const VisibilityLevel expected = VisibilityLevel.Public;
            var sut = new ProjectSnippetRepository(_requestFactory);

            await sut.Update(0, 0, visibilityLevel : expected);

            _request.Received().AddParameterIfNotNull("visibility_level", expected);
        }
コード例 #8
0
        public async Task Update_ValidParameters_AddsProjectIdUrlSegment()
        {
            const uint expected = 0;
            var        sut      = new ProjectSnippetRepository(_requestFactory);

            await sut.Update(0, expected);

            _request.Received().AddUrlSegment("projectId", expected);
        }
コード例 #9
0
        public async Task Update_TitleIsSet_AddsTitleParameter()
        {
            const string expected = "title";
            var          sut      = new ProjectSnippetRepository(_requestFactory);

            await sut.Update(0, 0, expected);

            _request.Received().AddParameterIfNotNull("title", expected);
        }
コード例 #10
0
        public async Task GetContent_ValidParameters_AddsIdUrlSegment()
        {
            const uint expected = 0;
            var        sut      = new ProjectSnippetRepository(_requestFactory);

            await sut.GetContent(expected, 0);

            _request.Received().AddUrlSegment("id", expected);
        }
コード例 #11
0
        public async Task GetAll_ResultsPerPageIsSet_AddsPerPageParameter()
        {
            const uint expected = 5;
            var        sut      = new ProjectSnippetRepository(_requestFactory);

            await sut.GetAll(0, resultsPerPage : expected);

            _request.Received().AddParameter("per_page", expected);
        }
コード例 #12
0
        /// <summary> Creates a new <see cref="GitLabClient" /> instance. </summary>
        /// <param name="hostUri"> The GitLab server to connect to. </param>
        /// <param name="privateToken"> The private token to use when making requests to the GitLab API. </param>
        public GitLabClient(Uri hostUri, string privateToken = null)
        {
            if (hostUri == null)
            {
                throw new ArgumentNullException(nameof(hostUri));
            }

            var baseUri = new Uri(hostUri, ApiPath);

            _authenticator = new PrivateTokenAuthenticator(privateToken);
            var clientFactory  = new ClientFactory(baseUri, _authenticator);
            var requestFactory = new RequestFactory(clientFactory);

            Branches        = new BranchRepository(requestFactory);
            Builds          = new BuildRepository(requestFactory);
            BuildTriggers   = new BuildTriggerRepository(requestFactory);
            BuildVariables  = new BuildVariableRepository(requestFactory);
            Commits         = new CommitRepository(requestFactory);
            DeployKeys      = new DeployKeyRepository(requestFactory);
            Emails          = new EmailRepository(requestFactory);
            Files           = new FileRepository(requestFactory);
            GitLabLicense   = new GitLabLicenseRepository(requestFactory);
            GitLabSettings  = new GitLabSettingsRepository(requestFactory);
            Issues          = new IssueRepository(requestFactory);
            Keys            = new KeyRepository(requestFactory);
            Labels          = new LabelRepository(requestFactory);
            Licenses        = new LicenseRepository(requestFactory);
            MergeRequests   = new MergeRequestRepository(requestFactory);
            Milestones      = new MilestoneRepository(requestFactory);
            Namespaces      = new NamespaceRepository(requestFactory);
            ProjectSnippets = new ProjectSnippetRepository(requestFactory);
            Repositories    = new RepositoryRepository(requestFactory);
            Runners         = new RunnerRepository(requestFactory);
            Session         = new SessionRepository(requestFactory);
            SystemHooks     = new SystemHookRepository(requestFactory);
            Tags            = new TagRepository(requestFactory);
            Users           = new UserRepository(requestFactory);
            Projects        = new ProjectRepository(requestFactory);
            ProjectMembers  = new ProjectMemberRepository(requestFactory);
            GroupMembers    = new GroupMemberRepository(requestFactory);
        }
コード例 #13
0
        public async Task GetAll_ResultsPerPageIsLessThanMinimum_ThrowsArgumentOutOfRangeException()
        {
            var sut = new ProjectSnippetRepository(_requestFactory);

            await Assert.ThrowsAsync <ArgumentOutOfRangeException>(() => sut.GetAll(0, resultsPerPage: uint.MinValue));
        }