Пример #1
0
        public void Execute_ShouldReturnError_WhenLoadFails()
        {
            var        console = Container.Resolve <IConsole>();
            var        factory = Container.Resolve <IGitDependFileFactory>();
            string     dir;
            ReturnCode loadCode = ReturnCode.GitRepositoryNotFound;

            factory.Arrange(f => f.LoadFromDirectory(Arg.AnyString, out dir, out loadCode))
            .Returns(null as GitDependFile);

            StringBuilder output = new StringBuilder();

            console.Arrange(c => c.WriteLine(Arg.AnyObject))
            .DoInstead((object obj) =>
            {
                output.AppendLine(obj.ToString());
            });

            var options  = new ConfigSubOptions();
            var instance = new ShowConfigCommand(options);

            var code = instance.Execute();

            Assert.AreEqual(ReturnCode.GitRepositoryNotFound, code, "Invalid Return Code");
            Assert.AreEqual(string.Empty, output.ToString());
        }
Пример #2
0
        public void Execute_ShouldPrintExistingConfig_WhenConfigExistsInGitRepo()
        {
            var        console = Container.Resolve <IConsole>();
            var        factory = Container.Resolve <IGitDependFileFactory>();
            string     dir;
            ReturnCode loadCode = ReturnCode.Success;

            factory.Arrange(f => f.LoadFromDirectory(Arg.AnyString, out dir, out loadCode))
            .Returns(Lib2Config);

            StringBuilder output = new StringBuilder();

            console.Arrange(c => c.WriteLine(Arg.AnyObject))
            .DoInstead((object obj) =>
            {
                output.AppendLine(obj.ToString());
            });

            var options  = new ConfigSubOptions();
            var instance = new ShowConfigCommand(options);

            var code = instance.Execute();

            Assert.AreEqual(ReturnCode.Success, code, "Invalid Return Code");
            Assert.AreEqual(Lib2Config.ToString() + Environment.NewLine, output.ToString());
        }