public void ShouldProcessSlashAndBackSlashWhenReplacingRootToken(string path, string command, string expected) { var processor = new XmlLauncherConfigurationProcessor(); var actual = processor.ProcessLauncherLink(new Repository() { Path = path }, new XmlLauncherLink() { Commands = new List <XmlLauncherCommand>() { new XmlExecuteCommand() { Command = command }, new XmlXPathReplacerCommand() { FilePath = command } } }); Assert.That(((ExecuteCommand)actual.Commands[0]).Command, Is.EqualTo(expected)); Assert.That(((XPathReplacerCommand)actual.Commands[1]).FilePath, Is.EqualTo(expected)); }
public void ShouldReplaceRootTokenWithRootDirectory() { var reader = new Mock <IXmlLauncherConfigurationReader>(MockBehavior.Strict); reader.Setup(mock => mock.LoadFile("")).Returns(GetTemplateConfiguration()).Verifiable(); var settings = new UserSettings() { Repositories = new Dictionary <string, List <Repository> >() { { "XONE", new List <Repository>() { new Repository() { Name = "Jar-Jar", Path = "D:/Jar-Jar You Stink" }, new Repository() { Name = "Kirk", Path = "E:/Star Trek/Kirk_you_suck" } } } } }; var processor = new XmlLauncherConfigurationProcessor() { ConfigurationReader = reader.Object, Context = new OneLaunchContextMock() { UserSettings = settings } }; var actual = processor.Load("").ToList(); Assert.That(actual, Is.Not.Null); Assert.That(actual, Has.Count.EqualTo(2)); AssertNode(actual[0], "D:/Jar-Jar You Stink", "Jar-Jar"); AssertNode(actual[1], "E:/Star Trek/Kirk_you_suck", "Kirk"); }
public void ShouldShowErrorWhenTheTemplateRepoCannotBeFoundInTheUserSettings() { var message = new Mock <IMessageService>(MockBehavior.Strict); message .Setup(mock => mock.ShowErrorMessage("Unable to find repo type UNKNOWN in config file MyDocs/OneLauncher/UserSettings.json")) .Verifiable(); var loader = new Mock <IXmlLauncherConfigurationReader>(MockBehavior.Strict); loader .Setup(mock => mock.LoadFile(It.IsAny <string>())).Returns(new XmlLauncherConfiguration() { RepoType = "UNKNOWN", GenericTemplate = new XmlLauncherNode() }) .Verifiable(); var context = new OneLaunchContextMock() { UserSettings = new UserSettings() { Repositories = new Dictionary <string, List <Repository> >() // No repo, so "UNKNOWN" repo type won't be found }, ApplicationSettings = new ApplicationSettings() { UserSettingsDirectory = "MyDocs/OneLauncher", UserSettingsFileName = "UserSettings.json" } }; var processor = new XmlLauncherConfigurationProcessor() { MessageService = message.Object, ConfigurationReader = loader.Object, Context = context }; Assert.That(processor.Load("").ToList(), Has.Count.EqualTo(0)); message.VerifyAll(); }