public static StateMachine Build(this BuilderViewModel builder)
        {
            StateMachine machine = new StateMachine();

            builder.States.ToList().ForEach(s => {
                machine.States.Add(new State()
                {
                    Display = s.Display, Name = s.Name
                });
                if (s.IsEnd)
                {
                    machine.EndStates.Add(s.Name);
                }
                else if (s.IsBegin)
                {
                    machine.BeginState = s.Name;
                }
            });
            builder.Transitions.ToList().ForEach(t => {
                machine.Transitions.Add(new Transition()
                {
                    Display = t.Display,
                    //Name = t.Name,
                    OriginState      = t.From.Name,
                    DestinationState = t.To.Name
                });
            });

            return(machine);
        }
        public SolutionViewModel NewSolution(BuilderViewModel builder, DesignerViewModel designer, string solutionName, string solutionNamespace, string outputFilename, string company, string product, string version,
                                             string solutionPath, string templatePath)
        {
            builder.ProcessNewCommand(builder.SolutionsFolder);
            var solutionVM = designer.SelectedItem as SolutionViewModel;

            Assert.IsNotNull(solutionVM, "Couldn't find SolutionViewModel");

            solutionVM.SolutionName           = solutionName;
            solutionVM.Namespace              = solutionNamespace;
            solutionVM.OutputSolutionFileName = outputFilename;
            solutionVM.CompanyName            = company;
            solutionVM.ProductName            = product;
            solutionVM.ProductVersion         = version;
            solutionVM.SolutionPath           = solutionPath;
            solutionVM.TemplatePath           = templatePath;
            solutionVM.Update();
            // get the solution view model from the builder and return that instead of solutionVM
            Assert.AreNotEqual(0, builder.SolutionsFolder.Solutions.Count, "Couldn't find SolutionViewModel from builder");
            SolutionViewModel builderSolutionVM = builder.SolutionsFolder.Solutions[0];

            builderSolutionVM.SolutionPath = solutionPath;
            SaveSolution(builderSolutionVM);
            return(builderSolutionVM);
        }
        public void TestInitialize()
        {
            _template = new TemplateViewModel(new Template());
            _module   = new ModuleViewModel(new Module());
            UnitOfWork       unitOfWork     = new UnitOfWork(new ElogicSystemContext());
            ProductViewModel itemViewModel1 = new ProductViewModel(new Product()
            {
                ID = 1, Description = "TEST",
            });
            ProductViewModel itemViewModel2 = new ProductViewModel(new Product()
            {
                ID = 2, Description = "TEST2"
            });
            ProductViewModel itemViewModel3 = new ProductViewModel(new Product()
            {
                ID = 3, Description = "TEST2"
            });
            ModuleViewModel module1 = new ModuleViewModel(new Module());

            module1.Add(itemViewModel3);

            _template.Add(itemViewModel1);
            _template.Add(itemViewModel2);
            _template.Add(module1);
            _windowFactory    = new WindowFactoryMock();
            _windowService    = _windowFactory.GetWindowService(WindowType.PanelBuilderView);
            _builderViewModel = new BuilderViewModel(_windowService.Close, _windowFactory, _template, _module, unitOfWork);
        }
Esempio n. 4
0
        void PasteExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            BuilderViewModel builderView = ViewModelHelper.FindParentView <BuilderViewModel>(this);

            if (builderView != null)
            {
                Paste(builderView.PasteViewModel);
            }
        }
Esempio n. 5
0
        void CopyExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            BuilderViewModel builderView = ViewModelHelper.FindParentView <BuilderViewModel>(this);

            if (builderView != null && DataContext is IWorkspaceViewModel)
            {
                builderView.PasteViewModel = DataContext as IWorkspaceViewModel;
            }
        }
Esempio n. 6
0
 public static string GetBuilderHighRiskTdCssClass(BuilderViewModel model)
 {
     if (model.Risk == Risk.High)
     {
         return(Constants.BuilderHighRiskTdClass);
     }
     else
     {
         return(string.Empty);
     }
 }
        public BuilderViewModelTests()
        {
            var map = new Pillar[4, 4]
            {
                { new Pillar(0, 0, 100), new Pillar(1, 0, 100), new Pillar(2, 0, 1), new Pillar(3, 0, 100) },
                { new Pillar(0, 1, 100), new Pillar(1, 1, 100), new Pillar(2, 1, 2), new Pillar(3, 1, 100) },
                { new Pillar(0, 2, 100), new Pillar(1, 2, 100), new Pillar(2, 2, 3), new Pillar(3, 2, 100) },
                { new Pillar(0, 3, 100), new Pillar(1, 3, 100), new Pillar(2, 3, 4), new Pillar(3, 3, 100) },
            };

            _map       = new Map(map);
            _viewModel = new BuilderViewModel(_map);
        }
        public void NewDatabaseSource(BuilderViewModel builder, DesignerViewModel designer, SolutionViewModel solutionVM, string serverName, string databaseName, string templatePath)
        {
            solutionVM.SpecificationSourcesFolder.ProcessNewDatabaseSourceCommand();

            var newDBSource = new DatabaseSourceViewModel();
            var dbSource    = designer.SelectedItem as DatabaseSourceViewModel ?? newDBSource;

            Assert.AreNotSame(dbSource, newDBSource, "Couldn't find database source");
            dbSource.DatabaseTypeCode   = (int)DatabaseTypeCode.SqlServer;
            dbSource.SourceDbServerName = serverName;
            dbSource.SourceDbName       = databaseName;
            dbSource.TemplatePath       = templatePath;
            Assert.IsTrue(File.Exists(dbSource.TemplatePath), "Solution template not found!");
            dbSource.Order = 1;

            dbSource.Update();
            solutionVM.Update();
            solutionVM.SpecTemplatesFolder.LoadSpecTemplates(solutionVM.Solution);
            SaveSolution(solutionVM);
        }
Esempio n. 9
0
        public ActionResult Builder()
        {
            var url         = Request.ServerVariables["HTTP_URL"];
            var memeRequest = MemeRequest.FromUrl(url, Server);

            var meme = MemeUtilities.FindMeme(GlobalMemeConfiguration.Memes, memeRequest.Name);


            int memeLineCount;

            if (meme == null)
            {
                memeRequest.Name  = "ihyk";
                memeRequest.Lines = new List <string>()
                {
                    "I'll have you know I tried other meme generators", "and only wasted hours and hours of my life"
                };
                memeLineCount = GlobalMemeConfiguration.Memes[memeRequest.Name].Lines.Count;
            }
            else
            {
                memeLineCount = meme.Lines.Count;
            }

            var lines = Enumerable.Range(0, memeLineCount)
                        .Select((item, index)
                                => memeRequest.Lines.Count > index
                        ? memeRequest.Lines[index]
                        : string.Empty).ToList();

            var viewModel = new BuilderViewModel
            {
                Memes        = GlobalMemeConfiguration.Memes.GetMemes(),
                SelectedMeme = memeRequest.Name,
                Lines        = lines
            };

            return(View(viewModel));
        }
Esempio n. 10
0
        protected override void DoExecute(string playground)
        {
            TestLocaldb.Execute("sqllocaldb.exe", "stop v11.0");
            TestLocaldb.Execute("sqllocaldb.exe", "start v11.0");

            var dbName = "Northwind-" + Guid.NewGuid();

            mDatabaseFileName    = Path.Combine(playground, dbName + ".mdf");
            mDatabaseLogFileName = Path.Combine(playground, dbName + "_log.ldf");
            mTemplatesPath       = Path.Combine(playground, "Templates");

            // setup database
            NorthwindUtility.Create(dbName, mDatabaseFileName, mDatabaseLogFileName);
            var gettingStartedPath = Path.Combine(playground, "Pack");

            Directory.CreateDirectory(gettingStartedPath);

            // unpack sapmle pack to <Playground>\GettingStartedPack
            SamplePacksUtility.ExtractSampleCSharpSQLServerXmlTo(gettingStartedPath);
            var templateBaseDir = Path.Combine(playground, "Pack", "Sample_CSharp_SQLServer_MySQL_Xml", "Templates", "CSharp_VS2012");

            var solutionDesigner = new DesignerViewModel();
            var builder          = new BuilderViewModel();

            var solutionVM = NewSolution(builder,
                                         solutionDesigner,
                                         "TestSolution",
                                         "TestNamespace",
                                         "TestSolution.sln",
                                         "TestCompany",
                                         "TestProduct",
                                         "0.1",
                                         Path.Combine(playground, "TestSolution.xml"),
                                         Path.Combine(templateBaseDir, "SolutionFile.mpt"));

            NewDatabaseSource(builder,
                              solutionDesigner,
                              solutionVM,
                              @"(localdb)\v11.0",
                              mDatabaseFileName,
                              Path.Combine(gettingStartedPath, @"Sample_CSharp_SQLServer_MySQL_Xml\Specifications\SQLServer\MDLSqlModel.mps"));

            Assert.AreEqual(1, solutionVM.Solution.DatabaseSourceList.Count);

            var efbllProj = CreateNewProject(solutionVM,
                                             solutionDesigner,
                                             "EFBLL",
                                             "EFBLL",
                                             null,
                                             null,
                                             Path.Combine(templateBaseDir, "Project", "EntityFramework.mpt"),
                                             "BLL");

            Assert.AreEqual(1, solutionVM.Solution.DatabaseSourceList.Count);
            Assert.AreEqual(1, solutionVM.Solution.ProjectList.Count);

            var efdsProj = CreateNewProject(solutionVM,
                                            solutionDesigner,
                                            "EFDataServices",
                                            "EFDataServices",
                                            null,
                                            null,
                                            Path.Combine(templateBaseDir, "Project", "EFDataServices.mpt"),
                                            "DS");

            ReferenceProjects(solutionVM, efdsProj,
                              efbllProj.ProjectID);

            Assert.AreEqual(1, solutionVM.Solution.DatabaseSourceList.Count);
            Assert.AreEqual(2, solutionVM.Solution.ProjectList.Count);


            var vmProj = CreateNewProject(solutionVM,
                                          solutionDesigner,
                                          "ViewModels",
                                          "ViewModels",
                                          null,
                                          null,
                                          Path.Combine(templateBaseDir, "Project", "VMEFDS.mpt"),
                                          "VM");

            ReferenceProjects(solutionVM, vmProj,
                              efbllProj.ProjectID);

            Assert.AreEqual(1, solutionVM.Solution.DatabaseSourceList.Count);
            Assert.AreEqual(3, solutionVM.Solution.ProjectList.Count);

            var shellProj = CreateNewProject(solutionVM,
                                             solutionDesigner,
                                             "Shell",
                                             "Shell",
                                             null,
                                             null,
                                             Path.Combine(templateBaseDir, "Project", "WPFUI.mpt"),
                                             null);

            ReferenceProjects(solutionVM, shellProj,
                              vmProj.ProjectID);

            Assert.AreEqual(1, solutionVM.Solution.DatabaseSourceList.Count);
            Assert.AreEqual(4, solutionVM.Solution.ProjectList.Count);

            UpdateOutputSolution(solutionVM);

            Assert.IsTrue(File.Exists(Path.Combine(playground, "TestSolution.sln")), "Solution file has not been created!");
            Console.WriteLine("Calling MSBuild now");
            MSBuildUtility.Execute(Path.Combine(playground, "TestSolution.sln"),
                                   multiThreaded: true);
            Console.WriteLine("TEst finished for now");
        }
Esempio n. 11
0
        /* This tests creates a simple solution containing 1 feature and 1 entity (forward-engineered). There's 1
         * solution template, which iterates the entities and outputs a simple text file containing - featurename-entityname
         */
        protected override void DoExecute(string playground)
        {
            var solutionDesigner = new DesignerViewModel();
            var builder          = new BuilderViewModel();

            builder.ProcessNewCommand(builder.SolutionsFolder);
            var solutionVM = solutionDesigner.SelectedItem as SolutionViewModel;

            if (solutionVM == null)
            {
                throw new InvalidOperationException("Couldn't find SolutionViewModel");
            }
            solutionVM.SolutionName           = "TestSolution";
            solutionVM.Namespace              = "TestNamespace";
            solutionVM.OutputSolutionFileName = "TestSolution.sln";
            solutionVM.CompanyName            = "TestCompany";
            solutionVM.ProductName            = "TestProduct";
            solutionVM.ProductVersion         = "0.1";
            solutionVM.SolutionPath           = Path.Combine(playground, "TestSolution.xml");
            solutionVM.TemplatePath           = Path.Combine(playground, "SolutionFile.mpt");
            solutionVM.Update();
            var solution = solutionVM.Solution;

            if (solution == null)
            {
                throw new InvalidOperationException("Couldn't find Solution!");
            }
            solutionVM.UpdateCommand.Execute(null);
            solutionVM.SaveSolution();
            solutionVM.LoadSolution(solution, true);
            //solutionVM.Refresh(true, 3);
            if (solutionVM.CodeTemplatesFolder == null)
            {
                throw new InvalidOperationException("Couldn't find CodeTemplatesFolder");
            }
            solutionVM.CodeTemplatesFolder.ProcessNewCodeTemplateCommand();
            var newSolTpl        = new CodeTemplateViewModel();
            var solutionTemplate = solutionDesigner.SelectedItem as CodeTemplateViewModel ?? newSolTpl;

            Assert.AreNotSame(solutionTemplate, newSolTpl, "Couldn't find template!");

            solutionTemplate.TemplateName       = "SolutionFile";
            solutionTemplate.IsTopLevelTemplate = true;
            solutionTemplate.TemplateOutput     = "<%%=Solution.SolutionDirectory%%><%%-\\%%><%%=Solution.OutputSolutionFileName%%>\r\n" +
                                                  "<%%:\r\n" +
                                                  "    update(Path)\r\n" +
                                                  "%%>";
            solutionTemplate.TemplateContent = "<%%-Entities:\r\n" +
                                               "%%><%%:\r\n" +
                                               "foreach(Entity)\r\n" +
                                               "{\r\n" +
                                               "    <%%- - %%><%%=Feature.FeatureName%%><%%--%%><%%=Entity.EntityName%%><%%-\r\n" +
                                               "%%>\r\n" +
                                               "}%%>";
            solutionTemplate.Update();

            solutionVM.FeaturesFolder.ProcessNewFeatureCommand();

            var newFeature = new FeatureViewModel();
            var feature    = solutionDesigner.SelectedItem as FeatureViewModel ?? newFeature;

            Assert.AreNotSame(feature, newFeature, "Couldn't find feature!");

            feature.Solution    = solution;
            feature.FeatureName = "TestFeature";
            feature.UpdateCommand.Execute(null);
            solutionDesigner.ShowItemInTreeView(feature);


            feature.ProcessNewEntityCommand();

            var newEntity = new EntityViewModel();
            var entity    = solutionDesigner.SelectedItem as EntityViewModel ?? newEntity;

            Assert.AreNotSame(entity, newEntity, "Couldn't find entity!");

            entity.EntityName         = "TestEntity";
            entity.EntityTypeCode     = 3; // primary
            entity.IdentifierTypeCode = 1; // generated
            entity.Update();
            entity.LoadEntity(entity.Entity);

            entity.PropertiesFolder.ProcessNewPropertyCommand();

            var newProperty = new PropertyViewModel();
            var property    = solutionDesigner.SelectedItem as PropertyViewModel ?? newProperty;

            Assert.AreNotSame(property, newProperty, "Couldn't find Property!");

            solutionVM.UpdateCommand.Execute(null);
            solutionVM.SaveSolution();
            using (var resetEvent = new AutoResetEvent(false))
            {
                var updated = new EventHandler((sender, args) =>
                {
                    Console.WriteLine("Solution updated!");
                    resetEvent.Set();
                });
                solutionVM.Updated += updated;
                solutionVM.UpdateOutputSolution();
                Assert.IsTrue(resetEvent.WaitOne(EventWaitTimeout), "Timeout waiting for solution update!");
                solutionVM.Updated -= updated;
            }
            var expectedOutput = "Entities:\r\n" +
                                 " - TestFeature-TestEntity\r\n";
            var output = File.ReadAllText(Path.Combine(playground, "TestSolution.sln"));

            Assert.AreEqual(expectedOutput, output);
        }
        protected override void DoExecute(string playground)
        {
            TestLocaldb.Execute("sqllocaldb.exe", "stop v11.0");
            TestLocaldb.Execute("sqllocaldb.exe", "start v11.0");

            var dbName = "Northwind-" + Guid.NewGuid();

            mDatabaseFileName    = Path.Combine(playground, dbName + ".mdf");
            mDatabaseLogFileName = Path.Combine(playground, dbName + "_log.ldf");
            mTemplatesPath       = Path.Combine(playground, "Templates");

            // setup database
            NorthwindUtility.Create(dbName, mDatabaseFileName, mDatabaseLogFileName);
            var gettingStartedPath = Path.Combine(playground, "GettingStartedPack");

            Directory.CreateDirectory(gettingStartedPath);

            // unpack sapmle pack to <Playground>\GettingStartedPack
            SamplePacksUtility.ExtractGettingStartedTo(gettingStartedPath);

            var solutionDesigner = new DesignerViewModel();
            var builder          = new BuilderViewModel();
            var solutionVM       = NewSolution(builder,
                                               solutionDesigner,
                                               "TestSolution",
                                               "TestNamespace",
                                               "TestSolution.sln",
                                               "TestCompany",
                                               "TestProduct",
                                               "0.1",
                                               Path.Combine(playground, "TestSolution.xml"),
                                               Path.Combine(playground, Path.Combine(playground, "NorthwindSolutionFile.mpt")));

            solutionVM.Solution.OutputRequested += SolutionOnOutputRequested;

            #region create solution template
            if (solutionVM.CodeTemplatesFolder == null)
            {
                throw new InvalidOperationException("Couldn't find CodeTemplatesFolder");
            }

            solutionVM.CodeTemplatesFolder.ProcessNewCodeTemplateCommand();
            var newSolTpl        = new CodeTemplateViewModel();
            var solutionTemplate = solutionDesigner.SelectedItem as CodeTemplateViewModel ?? newSolTpl;
            Assert.AreNotSame(solutionTemplate, newSolTpl, "Couldn't find template!");

            solutionTemplate.TemplateName       = "NorthwindSolutionFile";
            solutionTemplate.IsTopLevelTemplate = true;
            solutionTemplate.TemplateOutput     = "<%%=Solution.SolutionDirectory%%><%%-\\%%><%%=Solution.OutputSolutionFileName%%>\r\n" +
                                                  "<%%:\r\n" +
                                                  "    update(Path)\r\n" +
                                                  "%%>";
            solutionTemplate.TemplateContent = "<%%-Entities:\r\n" +
                                               "%%><%%:\r\n" +
                                               "foreach(Entity)\r\n" +
                                               "{\r\n" +
                                               "    <%%- - %%><%%=Feature.FeatureName%%><%%--%%><%%=Entity.EntityName%%><%%-\r\n" +
                                               "%%>\r\n" +
                                               "}%%>";
            solutionTemplate.Update();
            solutionVM.TemplatePath = Path.Combine(playground, Path.Combine(playground, "NorthwindSolutionFile.mpt"));
            SaveSolution(solutionVM);
            solutionVM.CodeTemplatesFolder.LoadTemplates(solutionVM.Solution);

            #endregion create solution template

            NewDatabaseSource(builder,
                              solutionDesigner,
                              solutionVM,
                              @"(localdb)\v11.0",
                              mDatabaseFileName,
                              Path.Combine(gettingStartedPath, @"GettingStarted\Specifications\SQLServer\MDLSqlModel.mps"));

            BuildSolution(solutionVM);

            UpdateOutputSolution(solutionVM);

            var expectedOutput = "Entities:\r\n" +
                                 " - Domain-Category\r\n" +
                                 " - Domain-CustomerCustomerDemo\r\n" +
                                 " - Domain-CustomerDemographic\r\n" +
                                 " - Domain-Customer\r\n" +
                                 " - Domain-Employee\r\n" +
                                 " - Domain-EmployeeTerritory\r\n" +
                                 " - Domain-OrderDetail\r\n" +
                                 " - Domain-Order\r\n" +
                                 " - Domain-Product\r\n" +
                                 " - Domain-Region\r\n" +
                                 " - Domain-Shipper\r\n" +
                                 " - Domain-Supplier\r\n" +
                                 " - Domain-Territory\r\n";
            var output = File.ReadAllText(Path.Combine(playground, "TestSolution.sln"));
            Assert.AreEqual(expectedOutput, output);
        }