Пример #1
0
        public async Task Create_ValidParameters_SetsCorrectResourceAndMethod()
        {
            var sut = new BuildVariableRepository(_requestFactory);

            await sut.Create(0, "key", "value");

            _requestFactory.Received().Create("projects/{projectId}/variables", Method.Post);
        }
Пример #2
0
        public async Task GetAll_ValidParameters_SetsCorrectResourceAndMethod()
        {
            var sut = new BuildVariableRepository(_requestFactory);

            await sut.GetAll(0);

            _requestFactory.Received().Create("projects/{projectId}/variables", Method.Get);
        }
Пример #3
0
        public async Task Delete_ValidParameters_AddsKeyUrlSegment()
        {
            const string expected = "key";
            var          sut      = new BuildVariableRepository(_requestFactory);

            await sut.Delete(0, expected);

            _request.Received().AddUrlSegment("key", expected);
        }
Пример #4
0
        public async Task Create_ValidParameters_AddsValueParameter()
        {
            const string expected = "value";
            var          sut      = new BuildVariableRepository(_requestFactory);

            await sut.Create(0, "key", expected);

            _request.Received().AddParameter("value", expected);
        }
Пример #5
0
        public async Task Create_ValidParameters_AddsProjectIdUrlSegment()
        {
            const uint expected = 0;
            var        sut      = new BuildVariableRepository(_requestFactory);

            await sut.Create(expected, "key", "value");

            _request.Received().AddUrlSegment("projectId", expected);
        }
Пример #6
0
        public async Task GetAll_ValidParameters_AddsProjectIdUrlSegment()
        {
            const uint expected = 0;
            var        sut      = new BuildVariableRepository(_requestFactory);

            await sut.GetAll(expected);

            _request.Received().AddUrlSegment("projectId", expected);
        }
Пример #7
0
        public async Task GetAll_ResultsPerPageIsSet_AddsPerPageParameter()
        {
            const uint expected = 5;
            var        sut      = new BuildVariableRepository(_requestFactory);

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

            _request.Received().AddParameter("per_page", expected);
        }
Пример #8
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);
        }
Пример #9
0
        public async Task Delete_KeyIsNull_ThrowsArgumentNullException()
        {
            var sut = new BuildVariableRepository(_requestFactory);

            await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Delete(0, null));
        }
Пример #10
0
        public async Task Create_ValueIsNull_ThrowsArgumentNullException()
        {
            var sut = new BuildVariableRepository(_requestFactory);

            await Assert.ThrowsAsync <ArgumentNullException>(() => sut.Create(0, "key", null));
        }
Пример #11
0
        public async Task GetAll_ResultsPerPageIsLessThanMinimum_ThrowsArgumentOutOfRangeException()
        {
            var sut = new BuildVariableRepository(_requestFactory);

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