public void SetupTest()
        {
            _redirector = new MockRedirector();

            var output = TestData.GetTempPath("Cookiecutter", true);
            var outputProjectFolder = Path.Combine(output, "integration");
            var feedUrl             = new Uri(TestFeedPath);
            var installedPath       = TestInstalledTemplateFolderPath;
            var userConfigFilePath  = TestUserConfigFilePath;

            _gitClient               = GitClientProvider.Create(_redirector, null);
            _gitHubClient            = new GitHubClient();
            _cutterClient            = CookiecutterClientProvider.Create(null, _redirector);
            _telemetry               = new CookiecutterTelemetry(new TelemetryTestService());
            _installedTemplateSource = new LocalTemplateSource(installedPath, _gitClient);
            _gitHubTemplateSource    = new GitHubTemplateSource(_gitHubClient);
            _feedTemplateSource      = new FeedTemplateSource(feedUrl);
            _projectSystemClient     = new MockProjectSystemClient();

            _vm = new CookiecutterViewModel(
                _cutterClient,
                _gitHubClient,
                _gitClient,
                _telemetry,
                _redirector,
                _installedTemplateSource,
                _feedTemplateSource,
                _gitHubTemplateSource,
                ExecuteCommand,
                _projectSystemClient
                );

            _vm.UserConfigFilePath = userConfigFilePath;
            ((CookiecutterClient)_cutterClient).DefaultBasePath = outputProjectFolder;
        }
        private void ShowCookiecutterPage()
        {
            Debug.Assert(_cookiecutterPage == null);

            var outputWindow = OutputWindowRedirector.GetGeneral(this);

            Debug.Assert(outputWindow != null);

            ReportPrereqsEvent(true);

            string feedUrl = CookiecutterPackage.Instance.RecommendedFeed;

            if (string.IsNullOrEmpty(feedUrl))
            {
                feedUrl = UrlConstants.DefaultRecommendedFeed;
            }

            object commonIdeFolderPath;
            var    shell = (IVsShell)GetService(typeof(SVsShell));

            ErrorHandler.ThrowOnFailure(shell.GetProperty((int)__VSSPROPID.VSSPROPID_InstallDirectory, out commonIdeFolderPath));

            var gitClient = GitClientProvider.Create(outputWindow, commonIdeFolderPath as string);

            _cookiecutterPage = new CookiecutterContainerPage(outputWindow, CookiecutterTelemetry.Current, gitClient, new Uri(feedUrl), OpenGeneratedFolder, UpdateCommandUI);
            _cookiecutterPage.ContextMenuRequested += OnContextMenuRequested;
            _cookiecutterPage.InitializeAsync(CookiecutterPackage.Instance.CheckForTemplateUpdate).HandleAllExceptions(this, GetType()).DoNotWait();

            ((Frame)Content).Content = _cookiecutterPage;
        }
Example #3
0
        public async Task CloneNonExistentRepo()
        {
            var client = GitClientProvider.Create(null, null);

            var outputParentFolder = TestData.GetTempPath();

            try {
                await client.CloneAsync("https://github.com/Microsoft/non-existent-repo", outputParentFolder);

                Assert.Fail($"Failed to generate exception when cloning non-existent repository.");
            } catch (ProcessException ex) {
                Assert.AreNotEqual(0, ex.Result.StandardErrorLines.Length);
            }

            // Make sure failed clone is cleaned up
            Assert.AreEqual(0, Directory.GetDirectories(outputParentFolder).Length);
        }
Example #4
0
        public async Task CloneWindowsIncompatibleRepo()
        {
            var client = GitClientProvider.Create(null, null);

            var outputParentFolder = TestData.GetTempPath();

            try {
                // Clone a repo that uses folders with invalid characters on Windows
                await client.CloneAsync(GitHubWindowsIncompatibleRepoUrl, outputParentFolder);

                Assert.Fail($"Failed to generate exception when cloning repository. You should manually check that cloning '{GitHubWindowsIncompatibleRepoUrl}' still fails on Windows.");
            } catch (ProcessException ex) {
                Assert.AreNotEqual(0, ex.Result.StandardErrorLines.Length);
            }

            // Make sure failed clone is cleaned up
            Assert.AreEqual(0, Directory.GetDirectories(outputParentFolder).Length);
        }