public void EnumDefinedKeysUnknownKeyTest()
        {
            var values = CommandLineSwitchHelper.GetCommandsUsingEnum <TestEnum>(_defaultTestArgs).ToDictionary(x => x.Key,
                                                                                                                x => x.Value);

            Assert.AreEqual(3, values.Count);
        }
        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 EnumDefinedKeysNoValueTest()
        {
            var values = CommandLineSwitchHelper.GetCommandsUsingEnum <TestEnum>(_defaultTestArgs).ToDictionary(x => x.Key,
                                                                                                                x => x.Value);

            Assert.IsEmpty(values[TestEnum.d]);
        }
Ejemplo n.º 4
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();
            }
        }