public void Unsupported_MigrationsOnNetStandardClassLibrary()
        {
            var targetProject = Path.Combine(_fixture.TestProjectRoot, "NetStandardClassLibrary/project.json");

            var result = new AddMigration(targetProject, "Initial", _output)
                         .ExecuteWithCapturedOutput();

            AssertCommand.Fail(result);
            Assert.Contains(string.Format(ToolsDotNetStrings.ClassLibrariesNotSupported, "NetStandardClassLibrary"), result.StdErr);
        }
        public void ShowsErrorWhenMissingDesignDependency()
        {
            var targetProject = Path.Combine(_fixture.TestProjectRoot, "MissingDesignDependency/project.json");

            var result = new AddMigration(targetProject, "Initial", _output)
                         .ExecuteWithCapturedOutput();

            AssertCommand.Fail(result);
            Assert.Contains(ToolsStrings.DesignDependencyNotFound, result.StdErr);
        }
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object senderObj, EventArgs args)
        {
            if (senderObj is OleMenuCommand && args is OleMenuCmdEventArgs)
            {
                var solutionProcessor = new SolutionProcessor(_ide);
                var projects          = solutionProcessor.GetAllSolutionProjects();

                var messageBoxService = new MessageBoxService();
                var migrationService  = new MigrationService(messageBoxService);

                var viewModel = new AddMigrationViewModel(projects, solutionProcessor, migrationService, messageBoxService);
                var window    = new AddMigration(viewModel);

                messageBoxService.ShowInfoMessageFunc =
                    msg => showMessageBox(window, msg, MessageBoxImage.Information);
                messageBoxService.ShowErrorMessageFunc =
                    msg => showMessageBox(window, msg, MessageBoxImage.Error);
                messageBoxService.ShowWarningMessageFunc =
                    msg => showMessageBox(window, msg, MessageBoxImage.Warning);

                window.ShowModal();
            }
        }
예제 #4
0
        public void AddMigrationRunTest()
        {
            using (var service = base.ServiceCollection.BuildServiceProvider())
            {
                var function = new AddMigration(service);
                var result   = function.Run(new AddMigration.Parameters()
                {
                    DatabaseTypes = new Ncf.XncfBase.Functions.SelectionList(Ncf.XncfBase.Functions.SelectionType.CheckBoxList)
                    {
                        SelectedValues = new[] { MultipleDatabaseType.Sqlite.ToString(), /*, MultipleDatabaseType.SqlServer.ToString(), */ MultipleDatabaseType.MySql.ToString() }
                    },

                    //DbContextName = "XncfBuilderEntities",
                    //MigrationName = "AddConfig",
                    //ProjectPath = @"E:\Senparc项目\NeuCharFramework\NcfPackageSources\src\Extensions\Senparc.Xncf.XncfBuilder\Senparc.Xncf.XncfBuilder"

                    DbContextName = "MyAppSenparcEntities",
                    MigrationName = "Add_Counter",
                    ProjectPath   = @"E:\Senparc项目\NeuCharFramework\NCF\src\SenparcLive.Xncf.MyApp"
                });

                Console.WriteLine(result.ToJson(true).Replace("\\r", "\r").Replace("\\n", "\n"));
            }
        }
        private async Task showMessageBox(AddMigration owner, string text, MessageBoxImage icon)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            MessageBox.Show(owner, text, Strings.AddMigrationMenuItemTitle, MessageBoxButton.OK, icon);
        }