Esempio n. 1
0
        public void RdmpScript_NewObject_CatalogueItem(string cataCommand, string cataItemCommand, string expectedCataItemName)
        {
            foreach (var c in RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>())
            {
                c.DeleteInDatabase();
            }

            var runner = new ExecuteCommandRunner(new ExecuteCommandOptions()
            {
                Script = new RdmpScript()
                {
                    Commands = new[]
                    {
                        cataCommand,
                        cataItemCommand
                    }
                }
            });

            SetupMEF();

            var exitCode = runner.Run(RepositoryLocator, new ThrowImmediatelyDataLoadEventListener(), new ThrowImmediatelyCheckNotifier(), new GracefulCancellationToken());

            Assert.AreEqual(0, exitCode);
            Assert.AreEqual(1, RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>().Length);
            var ci = RepositoryLocator.CatalogueRepository.GetAllObjects <Catalogue>().Single().CatalogueItems.Single();

            Assert.AreEqual(expectedCataItemName, ci.Name);
        }
Esempio n. 2
0
        public void Test_SplitCommandLine_QuotesInStrings()
        {
            var vals = ExecuteCommandRunner.SplitCommandLine("NewObject CatalogueItem bb\"'bb'").ToArray();

            Assert.AreEqual("NewObject", vals[0]);
            Assert.AreEqual("CatalogueItem", vals[1]);
            Assert.AreEqual("bb\"'bb'", vals[2]);
        }
Esempio n. 3
0
        public void Test_SplitCommandLine()
        {
            var vals = ExecuteCommandRunner.SplitCommandLine("NewObject CatalogueItem 'Catalogue:\"fff\"' 'bbbb'").ToArray();

            Assert.AreEqual("NewObject", vals[0]);
            Assert.AreEqual("CatalogueItem", vals[1]);
            Assert.AreEqual("Catalogue:\"fff\"", vals[2]);
            Assert.AreEqual("bbbb", vals[3]);
        }
Esempio n. 4
0
        /// <summary>
        /// Runs the provided string which should start after the cmd e.g. the bit after rdmp cmd
        /// </summary>
        /// <param name="command">1 string per piece following rdmp cmd.  Element 0 should be the Type of command to run</param>
        /// <returns></returns>
        protected int Run(params string[] command)
        {
            var opts = new ExecuteCommandOptions();

            opts.CommandName = command[0];
            opts.CommandArgs = command.Skip(1).ToArray();

            var runner = new ExecuteCommandRunner(opts);

            return(runner.Run(RepositoryLocator, new ThrowImmediatelyDataLoadEventListener(),
                              new ThrowImmediatelyCheckNotifier(), new GracefulCancellationToken()));
        }