Пример #1
0
        private Task ExecuteRunAsync(OpenPrMessage openPrMessage, Installation installation, long prId, out ILogger logger)
        {
            logger = Substitute.For <ILogger>();

            var context = Substitute.For <ExecutionContext>();

            context.FunctionDirectory = "data/functiondir";

            var installationTokenProvider = Substitute.For <IInstallationTokenProvider>();

            installationTokenProvider
            .GenerateAsync(Arg.Any <InstallationTokenParameters>(), Arg.Any <string>())
            .Returns(Task.FromResult(new InstallationToken
            {
                Token     = "token",
                ExpiresAt = "12345"
            }));

            var pullRequest = Substitute.For <IPullRequest>();

            pullRequest.OpenAsync(Arg.Any <GitHubClientParameters>()).Returns(x => Task.FromResult(new Pr(installation.Owner)
            {
                Id = prId
            }));

            var settingsTable = Substitute.For <CloudTable>(new Uri("https://myaccount.table.core.windows.net/Tables/settings"));

            var prs = Substitute.For <ICollector <Pr> >();

            return(OpenPr.RunAsync(openPrMessage, installation, prs, settingsTable, installationTokenProvider, pullRequest, logger, context));
        }
Пример #2
0
        private Task ExecuteRunAsync(OpenPrMessage openPrMessage, Installation installation, long prId, out ILogger logger)
        {
            logger = Substitute.For <ILogger>();

            var context = Substitute.For <ExecutionContext>();

            context.FunctionDirectory = "data/functiondir";

            var installationTokenProvider = Substitute.For <IInstallationTokenProvider>();

            installationTokenProvider
            .GenerateAsync(Arg.Any <InstallationTokenParameters>(), Arg.Any <StreamReader>())
            .Returns(Task.FromResult(new InstallationToken
            {
                Token     = "token",
                ExpiresAt = "12345"
            }));

            var pullRequest = Substitute.For <IPullRequest>();

            pullRequest.OpenAsync(Arg.Any <PullRequestParameters>()).Returns(x => Task.FromResult(prId));

            return(OpenPr.RunAsync(openPrMessage, installation, installationTokenProvider, pullRequest, logger, context));
        }