public void CorrectlyPrintsCommandsToConsoleAfterAlias() { // arrange var console = new Mock <IConsole>(); console.Setup(c => c.Width).Returns(80); var repl = new Mock <IRepl>(); var clearCommand = new ClearCommand(console.Object); var aliasCommand = new AliasCommand(console.Object); var commands = new Dictionary <string, IReplCommand> { { clearCommand.CommandName, clearCommand }, { aliasCommand.CommandName, aliasCommand }, }; repl.Setup(x => x.Commands).Returns(commands); var cmd = new HelpCommand(console.Object); aliasCommand.Execute(repl.Object, new[] { "clear", "clr" }); // act cmd.Execute(repl.Object, null); // assert // because we now have formatted wrapping with the description, we have to remove // all the extra spaces before verifying console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(" :" + clearCommand.CommandName) && f.Replace(" ", " ").Contains(clearCommand.Description))), Times.Once); console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(" :" + aliasCommand.CommandName) && f.Replace(" ", " ").Contains(aliasCommand.Description))), Times.Once); console.Verify(x => x.WriteLine(It.Is <string>(f => f.StartsWith(" :clr") && f.Replace(" ", " ").Contains(clearCommand.Description))), Times.Once); }
public void ShouldAliasCommandWithNewName() { // arrange var currentDir = @"C:\"; var dummyCommand = new Mock <IReplCommand>(); dummyCommand.Setup(x => x.CommandName).Returns("foo"); var fs = new Mock <IFileSystem>(); fs.Setup(x => x.BinFolder).Returns(Path.Combine(currentDir, "bin")); fs.Setup(x => x.DllCacheFolder).Returns(Path.Combine(currentDir, "cache")); var console = new Mock <IConsole>(); var executor = new Repl(null, fs.Object, null, null, null, null, null, new List <IReplCommand> { dummyCommand.Object }); var cmd = new AliasCommand(console.Object); // act cmd.Execute(executor, new[] { "foo", "bar" }); // assert executor.Commands.Count.ShouldEqual(2); executor.Commands["bar"].ShouldBeSameAs(executor.Commands["foo"]); }
public override bool Execute(PackagesInput input) { input.AppFolder = AliasCommand.AliasFolder(input.AppFolder).ToFullPath(); Execute(input, new FileSystem()); return(true); }
public void ShouldReturnAlias() { // act var cmd = new AliasCommand(new Mock <IConsole>().Object); // assert cmd.CommandName.ShouldEqual("alias"); }
public override bool Execute(InitializeInput input) { if (input.DeploymentFlag != null) { input.DeploymentFlag = AliasCommand.AliasFolder(input.DeploymentFlag); } return(Initialize(input, new FileSystem(), new SimpleLogger())); }
public void SetUp() { fileSystem = MockRepository.GenerateMock <IFileSystem>(); theRegistry = new AliasRegistry(); fileSystem.Stub(x => x.LoadFromFile <AliasRegistry>(AliasRegistry.ALIAS_FILE)) .Return(theRegistry); theCommand = new AliasCommand(); }
public void SetAliasForRomanNumber() { var romanNumber = DirectiveProxy <AliasCommandDirective> .Create("glob is I").Command.Execute() as RomanNumber; Assert.That(romanNumber, Is.Not.Null); Assert.That(romanNumber.Symbol, Is.EqualTo(SymbolEnum.I)); Assert.That(romanNumber.Value, Is.EqualTo(1)); Assert.That(romanNumber.Alias, Is.EqualTo("glob")); Assert.That(AliasCommand.GetRomanNumberByAlias("glob"), Is.Not.Null); }
public override bool Execute(AssemblyPackageInput input) { input.RootFolder = AliasCommand.AliasFolder(input.RootFolder); var zipService = new ZipFileService(); createZipFile(input, "WebContent", zipService); createZipFile(input, "Data", zipService); return(true); }
private static void WireUpAliasNotifications(IContainer container) { var commandList = container.Resolve <CommandList>(); AliasCommand aliasCommand = commandList.OfType <AliasCommand>().SingleOrDefault(); if (aliasCommand != null) { foreach (var command in commandList.OfType <BaseCommand>()) { aliasCommand.CommandAliasModified += (s, e) => command.NotifyWordsModified(); } } }
public void ShouldAliasCommandWithNewName( Mock <IFileSystem> fileSystem, Mock <IScriptEngine> engine, Mock <IObjectSerializer> serializer, TestLogProvider logProvider, Mock <IScriptLibraryComposer> composer, Mock <IConsole> console, Mock <IFilePreProcessor> filePreProcessor) { // arrange var currentDir = @"C:\"; var dummyCommand = new Mock <IReplCommand>(); dummyCommand.Setup(x => x.CommandName).Returns("foo"); fileSystem.Setup(x => x.BinFolder).Returns(Path.Combine(currentDir, "bin")); fileSystem.Setup(x => x.DllCacheFolder).Returns(Path.Combine(currentDir, "cache")); var executor = new Repl( new string[0], fileSystem.Object, engine.Object, serializer.Object, logProvider, composer.Object, console.Object, filePreProcessor.Object, new List <IReplCommand> { dummyCommand.Object }, new Printers(serializer.Object), new ScriptInfo()); var cmd = new AliasCommand(console.Object); // act cmd.Execute(executor, new[] { "foo", "bar" }); // assert executor.Commands.Count.ShouldEqual(2); executor.Commands["bar"].ShouldBeSameAs(executor.Commands["foo"]); }
public override bool Execute(InstallPackageInput input) { var applicationFolder = AliasCommand.AliasFolder(input.AppFolder); var packageFolder = FileSystem.Combine(applicationFolder, "bin", FubuMvcPackages.FubuPackagesFolder); var destinationFileName = FileSystem.Combine(packageFolder, Path.GetFileName(input.PackageFile)); if (input.UninstallFlag) { if (File.Exists(destinationFileName)) { Console.WriteLine("Deleting existing file " + destinationFileName); File.Delete(destinationFileName); } else { Console.WriteLine("File {0} does not exist", destinationFileName); } return(true); } if (!Directory.Exists(packageFolder)) { Console.WriteLine("Creating folder " + packageFolder); Directory.CreateDirectory(packageFolder); } if (File.Exists(destinationFileName)) { Console.WriteLine("Deleting existing file at " + destinationFileName); File.Delete(destinationFileName); } Console.WriteLine("Copying {0} to {1}", input.PackageFile, packageFolder); File.Copy(input.PackageFile, destinationFileName); return(true); }
public void SetUp() { fileSystem = MockRepository.GenerateMock<IFileSystem>(); theRegistry = new AliasRegistry(); fileSystem.Stub(x => x.LoadFromFile<AliasRegistry>(AliasRegistry.ALIAS_FILE)) .Return(theRegistry); theCommand = new AliasCommand(); }
public override bool Execute(InstallInput input) { input.AppFolder = AliasCommand.AliasFolder(input.AppFolder); Execute(input, new FileSystem()); return(true); }