private void Projects_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { ClearProject(); if (Projects.SelectedValue == null) { return; } var projectName = Projects.SelectedValue.ToString(); if (String.IsNullOrEmpty(projectName)) { return; } Schemas.ItemsSource = null; Tables.ItemsSource = null; _currentProject = _solution.GetProject(projectName); if (string.IsNullOrEmpty(_currentProject.GetScript(ScriptType.PostDeploy))) { MessageBox.Show( "The project needs a post deploy script - add one anywhere in the project and refresh", "MergeUi"); return; } Schemas.ItemsSource = _currentProject.GetSchemas(); }
public void Finds_Can_Add_Tables_After_Initial_Load() { var projectList = new List <ProjectDescriptor>(); var project = new ProjectDescriptor(); const string projectName = "abcdef"; project.Name = projectName; const string path = "c:\\dac.dacpac"; project.DacPath = path; projectList.Add(project); var enumerator = new Mock <ProjectEnumerator>(); enumerator.Setup(p => p.EnumerateProjects()).Returns(projectList); var tables = new List <ITable>(); tables.Add(new Table() { Name = "oooh", SchemaName = "dbo" }); var parser = new Mock <DacParser>(); parser.Setup(p => p.PreDeployScript).Returns(() => null); parser.Setup(p => p.PostDeployScript).Returns(() => null); parser.Setup(p => p.GetTableDefinitions()).Returns(tables); var parserBuilder = new Mock <DacParserBuilder>(); parserBuilder.Setup(p => p.Build(path)).Returns(parser.Object); var solution = new SolutionParser(enumerator.Object, parserBuilder.Object, new DummyStatus()); var schema = solution.GetProject("abcdef").GetSchema("dbo"); Assert.AreEqual(1, schema.GetTables().Count); solution.AddTable("abcdef", "dbo", "erm", new Table() { Name = "erm", SchemaName = "dbo" }); Assert.AreEqual(2, schema.GetTables().Count); var table = solution.GetTable("abcdef", "dbo", "erm"); Assert.IsNotNull(table); }
public void Finds_Schemas() { var projectList = new List <ProjectDescriptor>(); var project = new ProjectDescriptor(); const string projectName = "abcdef"; project.Name = projectName; const string path = "c:\\dac.dacpac"; project.DacPath = path; projectList.Add(project); var enumerator = new Mock <ProjectEnumerator>(); enumerator.Setup(p => p.EnumerateProjects()).Returns(projectList); var tables = new List <ITable>(); tables.Add(new Table() { SchemaName = "one", Name = "table" }); tables.Add(new Table() { SchemaName = "one", Name = "table2" }); tables.Add(new Table() { SchemaName = "two", Name = "table" }); var parser = new Mock <DacParser>(); parser.Setup(p => p.PreDeployScript).Returns(() => null); parser.Setup(p => p.PostDeployScript).Returns(() => null); parser.Setup(p => p.GetTableDefinitions()).Returns(tables); var parserBuilder = new Mock <DacParserBuilder>(); parserBuilder.Setup(p => p.Build(path)).Returns(parser.Object); var solution = new SolutionParser(enumerator.Object, parserBuilder.Object, new DummyStatus()); var actualProject = solution.GetProject(projectName); Assert.AreEqual(2, actualProject.GetSchemas().Count); }