public void SimpleSwitch2ValueTest()
        {
            var values = CommandLineSwitchHelper.GetCommands(_defaultTestArgs).ToDictionary(x => x.Key, x => x.Value);

            Assert.AreEqual("20", values["b"][0]);
            Assert.AreEqual("asdf", values["b"][1]);
        }
        public void EnumDefinedKeysValueTest()
        {
            var values = CommandLineSwitchHelper.GetCommandsUsingEnum <TestEnum>(_defaultTestArgs).ToDictionary(x => x.Key,
                                                                                                                x => x.Value);

            Assert.AreEqual("50", values[TestEnum.a].First());
        }
        public void EnumDefinedKeysUnknownKeyTest()
        {
            var values = CommandLineSwitchHelper.GetCommandsUsingEnum <TestEnum>(_defaultTestArgs).ToDictionary(x => x.Key,
                                                                                                                x => x.Value);

            Assert.AreEqual(3, values.Count);
        }
        public void EnumDefinedKeysNoValueTest()
        {
            var values = CommandLineSwitchHelper.GetCommandsUsingEnum <TestEnum>(_defaultTestArgs).ToDictionary(x => x.Key,
                                                                                                                x => x.Value);

            Assert.IsEmpty(values[TestEnum.d]);
        }
示例#5
0
        static void Main(string[] args)
        {
            log.Info("Starting editor...");

            ThreadAsserts.IsMainThread();

#if DEBUG
            WinFormExceptionHelper.AddUnhandledExceptionHooks();
#endif

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Check for a valid path to the development content
            if (ContentPaths.Dev == null)
            {
                const string errmsg =
                    @"Could not find the path to the development content (ContentPaths.Dev). The file containing this path should be located at:
    \Content\Data\devpath.txt

The path to the development content is required by the editor. See the file mentioned above for details.";
                MessageBox.Show(errmsg, "Error finding content path", MessageBoxButtons.OK);
                return;
            }

            // Ensure the content is copied over
            if (!ContentPaths.TryCopyContent(userArgs: CommonConfig.TryCopyContentArgs))
            {
                const string errmsg =
                    "Failed to copy the content from the dev to build path." +
                    " Content in the build path will likely not update to reflect changes made in the content in the dev path.";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg);
                }
                Debug.Fail(errmsg);
            }

            // Initialize stuff
            EngineSettingsInitializer.Initialize();
            try
            {
                GlobalState.Initialize();

                // Get the command-line switches
                var switches   = CommandLineSwitchHelper.GetCommandsUsingEnum <CommandLineSwitch>(args).ToArray();
                var showEditor = !HandleSwitches(switches);

                if (showEditor)
                {
                    // Start up the application
                    Application.Run(new MainForm());
                }
            }
            finally
            {
                GlobalState.Destroy();
            }
        }
        public void SimpleSwitchNoValueTest()
        {
            var values = CommandLineSwitchHelper.GetCommands(_defaultTestArgs).ToDictionary(x => x.Key, x => x.Value);

            Assert.IsEmpty(values["d"]);
        }
        public void SimpleSwitchExtraPrefixesTest()
        {
            var values = CommandLineSwitchHelper.GetCommands(_defaultTestArgs).ToDictionary(x => x.Key, x => x.Value);

            Assert.AreEqual("asdfa", values["c"].First());
        }
        public void SimpleSwitch1ValueTest()
        {
            var values = CommandLineSwitchHelper.GetCommands(_defaultTestArgs).ToDictionary(x => x.Key, x => x.Value);

            Assert.AreEqual("50", values["a"].First());
        }
        public void MainKeyTest()
        {
            var values = CommandLineSwitchHelper.GetCommands(_defaultTestArgs).ToDictionary(x => x.Key, x => x.Value);

            Assert.AreEqual("my main value", values[CommandLineSwitchHelper.PrimaryKeyName].First());
        }