public void Initialize() { bucket = new Bucket(); tester = new TesterIOConsole(); eventArgs = new Mock <EventArgs>(); fileSystem = new Mock <IFileSystem>(); process = new Mock <IProcessExecutor>(); io = tester.Mock( AbstractTester.OptionVerbosity(OutputOptions.VerbosityVeryVerbose), AbstractTester.OptionStdErrorSeparately(true)); dispatcher = new BEventDispatcher(bucket, io, process.Object, fileSystem.Object); package = new Mock <IPackageRoot>(); config = new Config(); bucket.SetPackage(package.Object); bucket.SetConfig(config); }
public void TestInitialize() { root = Helper.Fixtrue("Plugin"); repositoryInstalled = new Mock <IRepositoryInstalled>(); tester = new TesterIOConsole(); io = tester.Mock(AbstractTester.OptionVerbosity(OutputOptions.VerbosityDebug)); bucket = new Bucket(); config = new Config(); dispatcher = new BEventDispatcher(bucket, io); pluginManager = new PluginManager(io, bucket); repositoryManager = new Mock <RepositoryManager>(io, config, dispatcher, null); repositoryInstalled = new Mock <IRepositoryInstalled>(); installationManager = new Mock <InstallationManager>(); repositoryManager.Setup((o) => o.GetLocalInstalledRepository()).Returns(repositoryInstalled.Object); installationManager.Setup((o) => o.GetInstalledPath(It.IsAny <IPackage>())) .Returns(root); bucket.SetConfig(config); bucket.SetPluginManager(pluginManager); bucket.SetEventDispatcher(dispatcher); bucket.SetRepositoryManager(repositoryManager.Object); bucket.SetInstallationManager(installationManager.Object); }
public void TestHasLocalChangeInteractWithUser() { var packageMock = new Mock <IPackage>(); packageMock.Setup((o) => o.GetSourceReference()) .Returns("ref"); packageMock.Setup((o) => o.GetSourceUris()) .Returns(new[] { "https://github.com/bucket/bucket" }); packageMock.Setup((o) => o.GetVersion()) .Returns("1.0.0.0"); var processMock = new Mock <IProcessExecutor>(); var expectedGitCommand = WinCompat("git show-ref --head -d"); processMock.Setup(expectedGitCommand, expectedCwd: WinCompat(root)); expectedGitCommand = WinCompat("git status --porcelain --untracked-files=no"); var stdout = @" M 1-foo/bar.cs M 2-foo/baz.cs M 3-foobar.json M 4-foo/aux/bar.cs M 5-foobar.json M 6-foo/aux/bar.cs M 7-foo/aux/bar.cs M 8-foo/aux/bar.cs M 9-foo/aux/bar.cs M 10-foo/aux/bar.cs M 11-foo/aux/bar.cs M 12-foo/aux/bar.cs "; processMock.Setup(expectedGitCommand, actualOut: stdout, expectedCwd: WinCompat(root)); expectedGitCommand = WinCompat("git stash --include-untracked"); processMock.Setup(expectedGitCommand, expectedCwd: WinCompat(root)); expectedGitCommand = WinCompat("git diff HEAD"); stdout = @"index 8ba5bbe..9cda3f0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ foobarbaz foobarbaz +foo foobarbaz foobarbaz "; processMock.Setup(expectedGitCommand, actualOut: stdout, expectedCwd: WinCompat(root)); expectedGitCommand = WinCompat("git stash pop"); processMock.Setup(expectedGitCommand, expectedCwd: WinCompat(root)); expectedGitCommand = WinCompat("git log ref..ref --pretty=format:'%h - %an: %s'"); stdout = @"c5bd155 - foo: bar ccf0f2f - bar: baz ac027b9 - foo: baz"; processMock.Setup(expectedGitCommand, actualOut: stdout, expectedCwd: WinCompat(root)); if (!Directory.Exists(root + "/.git")) { Directory.CreateDirectory(root + "/.git"); } tester.SetInputs(new[] { "v", "d", "?", "s" }); io = tester.Mock(AbstractTester.OptionVerbosity(OutputOptions.VerbosityVerbose)); var downloader = CreateDownloaderMock(process: processMock.Object); downloader.Update(packageMock.Object, packageMock.Object, root); var display = tester.GetDisplay(); StringAssert.Contains(display, "The package has modified files"); StringAssert.Contains(display, "2 more files modified, choose \"v\" to view the full list."); StringAssert.Contains(display, "Discard changes [y,n,v,d,s,?,h]?"); StringAssert.Contains(display, "stash changes and try to reapply them after the update."); StringAssert.Contains(display, "Re-applying stashed changes"); StringAssert.Contains(display, "Pulling in changes:"); processMock.VerifyAll(); }