Наследование: BaseViewModel, IPullRequestCreationViewModel, IDisposable
    public async Task CreatingPRs(int testId,
        string repoName, string sourceRepoOwner, string sourceBranchName,
        bool repoIsFork, bool sourceBranchIsTracking,
        string targetRepoOwner, string targetBranchName,
        string title, string body)
    {
        var remote = "origin";
        var data = PrepareTestData(repoName, sourceRepoOwner, sourceBranchName, targetRepoOwner, targetBranchName, "origin",
            repoIsFork, sourceBranchIsTracking);

        var targetRepo = data.TargetRepo;
        var gitClient = data.GitClient;
        var l2repo = data.L2Repo;
        var activeRepo = data.ActiveRepo;
        var sourceBranch = data.SourceBranch;
        var targetBranch = data.TargetBranch;
        var ms = data.ModelService;

        var prservice = new PullRequestService(data.GitClient, data.GitService, data.ServiceProvider.GetOperatingSystem(), Substitute.For<IUsageTracker>());
        var vm = new PullRequestCreationViewModel(data.RepositoryHost, data.ActiveRepo, prservice, data.NotificationService);

        vm.Initialize();

        // the user has to input this
        vm.PRTitle = title;

        // this is optional
        if (body != null)
            vm.Description = body;

        // the TargetBranch property gets set to whatever the repo default is (we assume master here),
        // so we only set it manually to emulate the user selecting a different target branch
        if (targetBranchName != "master")
            vm.TargetBranch = new BranchModel(targetBranchName, targetRepo);

        await vm.CreatePullRequest.ExecuteAsync();

        var unused2 = gitClient.Received().Push(l2repo, sourceBranchName, remote);
        if (!sourceBranchIsTracking)
            unused2 = gitClient.Received().SetTrackingBranch(l2repo, sourceBranchName, remote);
        else
            unused2 = gitClient.DidNotReceiveWithAnyArgs().SetTrackingBranch(Args.LibGit2Repo, Args.String, Args.String);
        var unused = ms.Received().CreatePullRequest(activeRepo, targetRepo, sourceBranch, targetBranch, title, body ?? String.Empty);
    }
    public void TemplateIsUsedIfPresent()
    {
        var data = PrepareTestData("stuff", "owner", "master", "owner", "master",
            "origin", false, true);

        var prservice = Substitute.For<IPullRequestService>();
        prservice.GetPullRequestTemplate(data.ActiveRepo).Returns(Observable.Return("Test PR template"));

        var vm = new PullRequestCreationViewModel(data.RepositoryHost, data.ActiveRepo, prservice, data.NotificationService);
        vm.Initialize();

        Assert.Equal("Test PR template", vm.Description);
    }
 public void TargetBranchDisplayNameIncludesRepoOwnerWhenFork()
 {
     var data = PrepareTestData("octokit.net", "shana", "master", "octokit", "master", "origin", true, true);
     var prservice = new PullRequestService(data.GitClient, data.GitService, data.ServiceProvider.GetOperatingSystem(), Substitute.For<IUsageTracker>());
     prservice.GetPullRequestTemplate(data.ActiveRepo).Returns(Observable.Empty<string>());
     var vm = new PullRequestCreationViewModel(data.RepositoryHost, data.ActiveRepo, prservice, data.NotificationService);
     Assert.Equal("octokit/master", vm.TargetBranch.DisplayName);
 }