Exemplo n.º 1
0
        public void GitHubSettingsTest()
        {
            const string expectedGitHubRepositoryOwner = "foo";
            const string expectedGitHubRepositoryName  = "bar";
            const string expectedGitHubPat             = "baz";

            Setup(expectedGitHubRepositoryOwner,
                  expectedGitHubRepositoryName,
                  expectedGitHubPat,
                  "qux",
                  "https://dev.azure.com/quux/foobar",
                  "corge");

            var startup = new StartupMock();
            var mock    = new WebJobsBuilderMock(new ServiceCollection());

            startup.Configure(mock);
            var provider = mock.Services.BuildServiceProvider();
            var context  = provider.GetService <IGitHubRepositoryContext>();
            var iClient  = provider.GetService <IGitHubClient>();

            Assert.Equal(expectedGitHubRepositoryOwner, context.Owner);
            Assert.Equal(expectedGitHubRepositoryName, context.Name);
            GitHubClient client = (GitHubClient)iClient;

            Assert.Equal(expectedGitHubRepositoryOwner, client.Credentials.Login);
            Assert.Equal(expectedGitHubPat, client.Credentials.Password);
        }
Exemplo n.º 2
0
        public void SetUpWorkItemRepository()
        {
            Setup("foo", "bar", "baz", "qux", "https://dev.azure.com/quux/foobar", "corge");
            var startup = new StartupMock();
            var mock    = new WebJobsBuilderMock(new ServiceCollection());

            startup.Configure(mock);
            var provider           = mock.Services.BuildServiceProvider();
            var workItemRepository = provider.GetService <IWorkItemRepository>();

            Assert.NotNull(workItemRepository);
        }
Exemplo n.º 3
0
        public void SetUpRepositories()
        {
            Setup("foo", "bar", "baz", "qux", "https://dev.azure.com/quux/foobar", "corge");
            var startup = new StartupMock();
            var mock    = new WebJobsBuilderMock(new ServiceCollection());

            startup.Configure(mock);
            var provider = mock.Services.BuildServiceProvider();

            var gitHubRepository = provider.GetService <IGitHubRepository>();

            Assert.NotNull(gitHubRepository);
            Assert.NotNull(((GitHubRepository)gitHubRepository).client);

            var sonarCloudRepository = provider.GetService <ISonarCloudRepository>();

            Assert.NotNull(sonarCloudRepository);
            Assert.NotNull(((SonarCloudRepository)sonarCloudRepository).context);
        }
Exemplo n.º 4
0
        public void SonarCloudSettingsTest()
        {
            const string sonarCloudPat = "foo";

            Setup("bar",
                  "baz",
                  "qux",
                  sonarCloudPat,
                  "https://dev.azure.com/quux/foobar",
                  "corge");

            var expectedAuthorizationParameter = Convert.ToBase64String(
                System.Text.Encoding.ASCII.GetBytes(
                    string.Format("{0}:{1}", sonarCloudPat, "")));
            var startup = new StartupMock();
            var mock    = new WebJobsBuilderMock(new ServiceCollection());

            startup.Configure(mock);
            var provider = mock.Services.BuildServiceProvider();
            var iContext = provider.GetService <IRestClientContext>();
            var context  = (RestClientContext)iContext;

            Assert.Equal(expectedAuthorizationParameter, context.client.DefaultRequestHeaders.Authorization.Parameter);
        }