Exemplo n.º 1
0
        public void TestHasLocalChangeDisabledInteractWithUser()
        {
            var config = new Config();
            var merged = new JObject
            {
                ["config"] = new JObject(),
            };

            merged["config"][Settings.DiscardChanges] = true;
            config.Merge(merged);

            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 foo/bar.cs
 M foo/baz.cs
";

            processMock.Setup(expectedGitCommand, actualOut: stdout, expectedCwd: WinCompat(root));

            expectedGitCommand = WinCompat("git reset --hard");
            processMock.Setup(expectedGitCommand, expectedCwd: WinCompat(root));

            if (!Directory.Exists(root + "/.git"))
            {
                Directory.CreateDirectory(root + "/.git");
            }

            io = tester.Mock(
                AbstractTester.OptionVerbosity(OutputOptions.VerbosityVerbose),
                AbstractTester.Interactive(false));

            var downloader = CreateDownloaderMock(config: config, process: processMock.Object);

            downloader.Update(packageMock.Object, packageMock.Object, root);

            processMock.VerifyAll();
        }
Exemplo n.º 2
0
        public void TestTesterIOConsoleTrack()
        {
            var tester = new TesterIOConsole();

            tester.SetInputs(new[] { "menghanyu" });

            var io = tester.Track(
                new IOConsole(null, null),
                AbstractTester.OptionStdErrorSeparately(true),
                AbstractTester.Interactive(false));

            Assert.AreEqual("miaomiao", (string)io.Ask("what's your name?", "miaomiao"));

            io.Write("hello world");
            Assert.AreEqual(
                @"hello world
", tester.GetDisplay());

            io.WriteError("hello world error");
            Assert.AreEqual(
                @"hello world error
", tester.GetDisplayError());
        }