public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
 {
     var context = new Context(automationObject, replacementsDictionary);
     var workflow = new Workflow(context.SolutionPath,
                                      new SqlServer(),
                                      new FileSystem(),
                                      new MessageBox(),
                                      new TableDefinitionDialog(new SqlServer()),
                                      context.TemplateService);
     workflow.Run(context.RootName);
 }
        public void Dont_Create_Table_When_Dialog_Creates_Table_And_Template_Creation_Is_Not_Successful()
        {
            var templateService = MockRepository.GenerateStub<ITemplateService>();
            templateService.Stub(x => x.Render(null, null)).IgnoreArguments().Return(new TransformResult(null, Enumerable.Repeat(new Exception(), 1)));

            var databaseService = MockRepository.GenerateStub<IData>();
            databaseService.Stub(x => x.Execute(null, null, null)).IgnoreArguments();

            var fileSystem = MockRepository.GenerateStub<IFileSystem>();
            fileSystem.Stub(x => x.FindFirst(null, null)).IgnoreArguments().Return(Maybe.Just(string.Empty));

            var workflow = new Workflow(null,
                                             databaseService,
                                             fileSystem,
                                             MockRepository.GenerateStub<IMessageBox>(),
                                             TableDefinitionDialogStub.CreateTable(),
                                             templateService);
            workflow.Run("default");

            databaseService.AssertWasNotCalled(x => x.Execute(null, null, null), x => x.IgnoreArguments());
        }
        public void Render_Is_Called_When_Dialog_Creates_Table()
        {
            var templateService = MockRepository.GenerateStub<ITemplateService>();
            templateService.Stub(x => x.Render(null, null)).IgnoreArguments().Return(new TransformResult(null, Enumerable.Empty<Exception>()));

            var fileSystem = MockRepository.GenerateStub<IFileSystem>();
            fileSystem.Stub(x => x.FindFirst(null, null)).IgnoreArguments().Return(Maybe.Just(string.Empty));

            var workflow = new Workflow(null,
                                             MockRepository.GenerateStub<IData>(),
                                             fileSystem,
                                             MockRepository.GenerateStub<IMessageBox>(),
                                             TableDefinitionDialogStub.CreateTable(),
                                             templateService);
            workflow.Run("default");

            templateService.AssertWasCalled(x => x.Render(null, null), x => x.IgnoreArguments());
        }
        public void Find_Template_File_Is_Called_When_Run()
        {
            var fileSystem = MockRepository.GenerateStub<IFileSystem>();
            fileSystem.Stub(x => x.FindFirst(null, null)).IgnoreArguments().Return(Maybe.Just(string.Empty));
            var workflow = new Workflow(SolutionPath,
                                             MockRepository.GenerateStub<IData>(),
                                             fileSystem,
                                             MockRepository.GenerateStub<IMessageBox>(),
                                             MockRepository.GenerateStub<ITableDefinitionDialog>(),
                                             MockRepository.GenerateStub<ITemplateService>());

            workflow.Run(null);

            fileSystem.AssertWasCalled(x => x.FindFirst(SolutionPath, Workflow.TableTemplateFilename));
        }
        public void Table_Definition_Dialog_Is_Not_Displayed_When_Run_And_Template_File_Is_Not_Found()
        {
            var dialog = MockRepository.GenerateStub<ITableDefinitionDialog>();
            var fileSystem = MockRepository.GenerateStub<IFileSystem>();
            fileSystem.Stub(x => x.FindFirst(null, null)).IgnoreArguments().Return(Maybe.Nothing<string>());
            var workflow = new Workflow(null,
                                             MockRepository.GenerateStub<IData>(),
                                             fileSystem,
                                             MockRepository.GenerateStub<IMessageBox>(),
                                             dialog,
                                             MockRepository.GenerateStub<ITemplateService>());
            workflow.Run(null);

            dialog.AssertWasNotCalled(x => x.Display(null, null, null), x => x.IgnoreArguments());
        }