public void itShouldNotRaiseExceptionWhenCtorArgsHasNonctorArgsElements() { var xmlConfig = @" <commandCenter> <commands> <command> <typeName>CommandCenter.Infrastructure.Tests, CommandCenter.Infrastructure.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> <ctorArgs> <ctorArg value='someValue'/> <!-- <ctorArg value='commentedOutForTesting'/> --> <anotherNonCtorArgElement /> </ctorArgs> </command> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); Assert.AreEqual(1, cmdConfigs.Count); }
public void itShouldNotLoadCommentedOutCommandConfigurations() { var xmlConfig = @" <commandCenter> <commands> <command> <typeName>CommandCenter.Infrastructure.Tests, CommandCenter.Infrastructure.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> </command> <!-- <command> <typeName>CommandCenter.Infrastructure.Tests, CommandCenter.Infrastructure.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> </command> --> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); Assert.AreEqual(1, cmdConfigs.Count); }
public List <CommandConfiguration> GetCommands(string configFile) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(configFile); var commandsConfigurationSource = new CommandsConfigurationXmlSource(xmlDoc); var commandConfigs = commandsConfigurationSource.GetCommandConfigurations().Where(c => c.Enabled).ToList(); var cmdBuilder = new CommandsBuilder(commandConfigs, commandsConfigurationSource.Tokens); return(cmdBuilder.GetTokenizedConfiguration()); }
public bool Run() { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(_commandsConfigFile); var commandsConfigurationSource = new CommandsConfigurationXmlSource(xmlDoc); var commandsConfiguration = commandsConfigurationSource.GetCommandConfigurations(); var commandsBuilder = new CommandsBuilder(commandsConfiguration); var commands = commandsBuilder.BuildCommands(); var commandsRunner = new CommandsRunner(commands); commandsRunner.OnReportSent += CommandsRunner_OnReportSent; return(commandsRunner.Run()); }
public void itShouldThrowExceptionIfEnabledAttributeValueIsNeitherTrueNorFalseNorEmpty() { var xmlConfig = $@" <commandCenter> <commands> <command enabled='werjwjekqrl'> <typeName>CommandCenter.Infrastructure.Tests, CommandCenter.Infrastructure.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> </command> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); }
public void itShouldRaiseExceptionWhenCommandNodeNotFound() { var xmlConfig = @" <commandCenter> <commands> <commandNodeNot> </commandNodeNot> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); Assert.AreEqual(0, cmdConfigs.Count); }
public void itShouldSetEnabledToTrueIfEnabledAttributeValueIsEmpty() { var xmlConfig = $@" <commandCenter> <commands> <command enabled=''> <typeName>CommandCenter.Infrastructure.Tests, CommandCenter.Infrastructure.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> </command> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); var cmdConfig = cmdConfigs.FirstOrDefault(); Assert.IsNotNull(cmdConfig); Assert.IsTrue(cmdConfig.Enabled); }
public void itShouldAssignEmptyStringIfShortDesriptionDoesNotExist() { var xmlConfig = $@" <commandCenter> <commands> <command> <typeName>CommandCenter.Infrastructure.Tests, CommandCenter.Infrastructure.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> </command> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); var cmdConfig = cmdConfigs.FirstOrDefault(); Assert.IsNotNull(cmdConfig); Assert.AreEqual(cmdConfig.ShortDescription, string.Empty); }
public void itShouldRaiseExceptionWhenTypeNameNotFound() { var xmlConfig = @" <commandCenter> <commands> <command> <ctorArgs> <ctorArg name='dummyName' value='dummyValue' /> </ctorArgs> </command> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); Assert.AreEqual(0, cmdConfigs.Count); }
public void itShouldRaiseNotExceptionWhenCtorNameAttributeIsOmitted() { var xmlConfig = @" <commandCenter> <commands> <command> <typeName>CommandCenter.Infrastructure.Tests, CommandCenter.Infrastructure.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> <ctorArgs> <ctorArg value='someValue'/> </ctorArgs> </command> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); Assert.AreEqual(1, cmdConfigs.Count); }
public void itShouldLoadCommandConfigurationsWithParameterElements() { var xmlConfig = @" <commandCenter> <commands> <command> <typeName>CommandCenter.Tests, CommandCenter.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> <ctorArgs> <ctorArg name='dummyName' value='dummyValue' /> </ctorArgs> </command> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); Assert.AreEqual(1, cmdConfigs.Count); }
public void itShouldGetShortDesriptionWhenItExists() { var shortDescText = "This is a test short description"; var xmlConfig = $@" <commandCenter> <commands> <command> <typeName>CommandCenter.Infrastructure.Tests, CommandCenter.Infrastructure.Tests.MockCommands.MockCommandWithNonDefaultConstructor</typeName> <shortDescription>{shortDescText}</shortDescription> </command> </commands> </commandCenter> "; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); var xmlConfigSource = new CommandsConfigurationXmlSource(xmlDoc); var cmdConfigs = xmlConfigSource.GetCommandConfigurations(); var cmdConfig = cmdConfigs.FirstOrDefault(); Assert.IsNotNull(cmdConfig); Assert.AreEqual(cmdConfig.ShortDescription, shortDescText); }