internal ProjectTreeNode(ISolutionDirectoryPathManagement solutionPath, UAModelDesignerProject projectDescription) : this(solutionPath, projectDescription.Name) { UAModelDesignerProject = projectDescription; ModelDesign _RootOfOPCUAInfromationModel = ModelDesign.CreateRootOfOPCUAInfromationModel(FileName); InitializeComponent(_RootOfOPCUAInfromationModel); }
public void OpenExistingModel() { Mock <ISolutionConfigurationManagement> _solutionMock = new Mock <ISolutionConfigurationManagement>(); _solutionMock.SetupGet(x => x.DefaultDirectory).Returns(m_TestSolutionPath); Mock <IGraphicalUserInterface> _guiuMocck = new Mock <IGraphicalUserInterface>(); UAModelDesignerProject _projectDescriptor = new UAModelDesignerProject() { BuildOutputDirectoryName = "15064369 - 0B00 - 4CA8 - BB0A - AB486AFCCA38", CSVFileName = "CSVFileName", FileName = @"DemoConfiguration\BoilerType.xml", Name = "TestProjectDescription", ProjectIdentifier = Guid.NewGuid().ToString() }; IProjectConfigurationManagement _newItemUnderTest = ProjectConfigurationManagement.ImportModelDesign(_solutionMock.Object, _guiuMocck.Object, _projectDescriptor); Assert.IsNotNull(_newItemUnderTest); Assert.AreEqual <string>(Path.Combine(Path.Combine(m_TestSolutionPath, "DemoConfiguration")), _newItemUnderTest.DefaultDirectory); Assert.AreEqual <string>(m_TestProjectPath, _newItemUnderTest.DefaultFileName); Assert.IsNotNull(_newItemUnderTest.ModelDesign); Assert.AreEqual <string>(@"http://tempuri.org/UA/Examples/BoilerType", _newItemUnderTest.ModelDesign.TargetNamespace); Assert.AreEqual <string>("TestProjectDescription", _newItemUnderTest.Name); Assert.IsNotNull(_newItemUnderTest.UAModelDesignerProject); Assert.AreEqual <string>(@"DemoConfiguration\BoilerType.xml", _newItemUnderTest.UAModelDesignerProject.FileName); }
void ISolutionConfigurationManagement.Save(bool prompt) { m_Server.Save(this); this.SelectSavePath(prompt, SetupFileDialog); List <UAModelDesignerProject> _projects = new List <UAModelDesignerProject>(); foreach (IProjectConfigurationManagement _item in m_Projects) { UAModelDesignerProject _projectDescriptor = _item.UAModelDesignerProject; string _effectiveAbsolutePath = _item.DefaultFileName; _projectDescriptor.FileName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _effectiveAbsolutePath); } string _codebaseRelativePathName = string.Empty; string _configurationRelativePathName = string.Empty; ServerSelector.ServerDescriptor _plugin = m_Server.ServerConfiguration; if (_plugin != null) { _codebaseRelativePathName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _plugin.Codebase); _configurationRelativePathName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _plugin.Configuration); } UAModelDesignerSolution _solutionDesription = new UAModelDesignerSolution() { Name = this.m_Name, Projects = m_Projects.Select <IProjectConfigurationManagement, UAModelDesignerProject>(x => x.UAModelDesignerProject).ToArray <UAModelDesignerProject>(), ServerDetails = new UAModelDesignerSolutionServerDetails { codebase = _codebaseRelativePathName, configuration = _configurationRelativePathName } }; this.Save(_solutionDesription); }
public void OpenExistingModelFailedTest() { Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>(); _directory.SetupGet(x => x.DefaultDirectory).Returns(Directory.GetCurrentDirectory()); UAModelDesignerProject _projectDescriptor = new UAModelDesignerProject() { BuildOutputDirectoryName = string.Empty, CSVFileName = "CSVFileName", FileName = "15064369 - 0B00 - 4CA8 - BB0A - AB486AFCCA38", Name = "TestProjectDescription", ProjectIdentifier = Guid.NewGuid().ToString() }; Mock <ISolutionConfigurationManagement> _solutionMock = new Mock <ISolutionConfigurationManagement>(); _solutionMock.SetupGet(x => x.DefaultDirectory).Returns(@"C:\a\b\c\"); Mock <IFileDialog> _IFileDialogMock = new Mock <IFileDialog>(); _IFileDialogMock.SetupGet(x => x.FileName).Throws <ApplicationException>(); _IFileDialogMock.SetupGet(x => x.InitialDirectory).Throws <ApplicationException>(); IProjectConfigurationManagement _newItem; Assert.ThrowsException <ArgumentNullException>(() => _newItem = ProjectConfigurationManagement.ImportModelDesign(null, new GraphicalUserInterface(_IFileDialogMock.Object), _projectDescriptor)); Assert.ThrowsException <ArgumentNullException>(() => _newItem = ProjectConfigurationManagement.ImportModelDesign(_solutionMock.Object, null, _projectDescriptor)); Assert.ThrowsException <ArgumentNullException>(() => _newItem = ProjectConfigurationManagement.ImportModelDesign(_solutionMock.Object, new GraphicalUserInterface(_IFileDialogMock.Object), null)); Assert.ThrowsException <FileNotFoundException>(() => _newItem = ProjectConfigurationManagement.ImportModelDesign(_solutionMock.Object, new GraphicalUserInterface(_IFileDialogMock.Object), _projectDescriptor)); }
internal ProjectTreeNode(IBaseDirectoryProvider solutionPath, UAModelDesignerProject projectDescription) : this(solutionPath, projectDescription.Name) { UAModelDesignerProject = projectDescription; ModelDesign _model = ReadConfiguration(); InitializeComponent(_model); }
private ProjectConfigurationManagement(bool newModel, UAModelDesignerProject uaModelDesignerProject, ISolutionConfigurationManagement solution, Tuple <OpcUaModelCompiler.ModelDesign, string> modelDesign, IGraphicalUserInterface gui) : base(modelDesign.Item2, newModel, gui) { m_UAModelDesignerProject = uaModelDesignerProject; m_ISolutionConfigurationManagement = solution; this.m_ModelDesign = modelDesign.Item1; m_NewModel = newModel; }
private void CheckConsistency(UAModelDesignerProject uaModelDesignerProject) { Assert.IsNotNull(uaModelDesignerProject); Assert.AreEqual <string>("$(ProjectFileName)", uaModelDesignerProject.BuildOutputDirectoryName); Assert.AreEqual <string>("$(ProjectFileName).csv", uaModelDesignerProject.CSVFileName); Assert.IsTrue(uaModelDesignerProject.FileName.StartsWith((@"Model_"))); Assert.IsTrue(uaModelDesignerProject.Name.StartsWith((@"Model_"))); Guid _projectIdentifier = Guid.Parse(uaModelDesignerProject.ProjectIdentifier); Assert.IsFalse(Guid.Empty == _projectIdentifier); }
private ProjectTreeNode(ISolutionDirectoryPathManagement solutionPath, string filePath, OPCFModelDesign model) : this(solutionPath, Path.GetFileNameWithoutExtension(filePath)) { UAModelDesignerProject = new UAModelDesignerProject() { BuildOutputDirectoryName = Resources.DefaultOutputBuildDirectory, CSVFileName = Resources.DefaultCSVFileName, FileName = RelativeFilePathsCalculator.TryComputeRelativePath(solutionPath.BaseDirectory, filePath), ProjectIdentifier = Guid.NewGuid().ToString(), Name = m_GetNextUniqueProjectName }; InitializeComponent(new ModelDesign(model, false)); }
internal ProjectTreeNode(IBaseDirectoryProvider solutionPath, string filePath, OPCFModelDesign model) : this(solutionPath, Path.GetFileNameWithoutExtension(filePath)) { UAModelDesignerProject = new UAModelDesignerProject() { BuildOutputDirectoryName = Resources.DefaultOutputBuildDirectory, CSVFileName = Resources.DefaultCSVFileName, FileName = GetRelativePath(filePath), ProjectIdentifier = Guid.NewGuid().ToString(), Name = UniqueProjectName }; InitializeComponent(new ModelDesign(model, false)); }
public void UAModelDesignerProjectCreateEmptyTest() { UAModelDesignerProject _newItem = UAModelDesignerProject.CreateEmpty("name"); Assert.IsNotNull(_newItem); Assert.AreEqual <string>("$(ProjectFileName)", _newItem.BuildOutputDirectoryName); Assert.AreEqual <string>("$(ProjectFileName).csv", _newItem.CSVFileName); Assert.AreEqual <string>("$(ProjectFileName).xml", _newItem.FileName); Assert.AreEqual <string>("name", _newItem.Name); Guid _projectId = Guid.Empty; Assert.IsTrue(Guid.TryParse(_newItem.ProjectIdentifier, out _projectId)); Assert.IsFalse(_projectId == Guid.Empty); }
public void MyTestMethod() { Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>(); _directory.SetupGet(x => x.BaseDirectory).Returns(@"C:\"); UAModelDesignerProject _projectDescriptor = new UAModelDesignerProject() { BuildOutputDirectoryName = string.Empty, CSVFileName = "CSVFileName", FileName = m_DemoConfigurationFilePath, Name = "TestProjectDescription", ProjectIdentifier = Guid.NewGuid().ToString() }; ProjectTreeNode _openProject = new ProjectTreeNode(_directory.Object, _projectDescriptor); }
/// <summary> /// Creates new model encapsulated by an instance of this class /// </summary> /// <param name="solution">The solution description.</param> /// <param name="gui">The graphical user interface.</param> /// <param name="projectName">Name of the project.</param> /// <returns><see cref="IProjectConfigurationManagement"/>.</returns> internal static IProjectConfigurationManagement CreateNew(ISolutionConfigurationManagement solution, IGraphicalUserInterface gui, string projectName) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (gui == null) { throw new ArgumentNullException(nameof(gui)); } UAModelDesignerProject _projectDescription = UAModelDesignerProject.CreateEmpty(projectName); //TODO Creating new project the existing one should not be overridden #174 string _defFilePath = Path.ChangeExtension(RelativeFilePathsCalculator.CalculateAbsoluteFileName(solution.DefaultDirectory, projectName), Resources.Project_FileDialogDefaultExt); return(new ProjectConfigurationManagement(true, _projectDescription, solution, new Tuple <OpcUaModelCompiler.ModelDesign, string>(OpcUaModelCompilerModelDesigner.GetDefault(), _defFilePath), gui)); }
public void BuildTest() { Mock <ISolutionConfigurationManagement> _solutionMock = new Mock <ISolutionConfigurationManagement>(); _solutionMock.SetupGet(x => x.DefaultDirectory).Returns(m_TestSolutionPath); Mock <IGraphicalUserInterface> _guiuMocck = new Mock <IGraphicalUserInterface>(); _guiuMocck.SetupGet(x => x.MessageBoxShowWarningAskYN).Returns(() => (t, c) => true); UAModelDesignerProject _projectDescriptor = _projectDescriptor = UAModelDesignerProject.CreateEmpty("BoilerType"); _projectDescriptor.FileName = @"DemoConfiguration\BoilerType.xml"; IProjectConfigurationManagement _newItemUnderTest = ProjectConfigurationManagement.ImportModelDesign(_solutionMock.Object, _guiuMocck.Object, _projectDescriptor); List <string> _log = new List <string>(); _newItemUnderTest.Build(x => _log.Add(x)); Assert.AreEqual <int>(4, _log.Count); Assert.IsTrue(Directory.Exists(Path.Combine(m_TestSolutionPath, @"DemoConfiguration\BoilerType"))); Assert.AreEqual(7, Directory.GetFiles(Path.Combine(m_TestSolutionPath, @"DemoConfiguration\BoilerType")).Length); }
internal static IProjectConfigurationManagement ImportNodeSet(ISolutionConfigurationManagement solution, IGraphicalUserInterface graphicalUserInterface, Action <TraceMessage> traceEvent) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (graphicalUserInterface == null) { throw new ArgumentNullException(nameof(graphicalUserInterface)); } Tuple <OpcUaModelCompiler.ModelDesign, string> _modelDesign = IO.ImportNodeSet.Import(solution.DefaultDirectory, traceEvent); if (_modelDesign == null) { return(null); } UAModelDesignerProject _newProjctDesription = UAModelDesignerProject.CreateEmpty(_modelDesign.Item2); return(new ProjectConfigurationManagement(true, _newProjctDesription, solution, _modelDesign, graphicalUserInterface)); }
private (string CSVFileName, string OutputDirectory) BuildCalculateFileNames() { UAModelDesignerProject _def = UAModelDesignerProject.CreateEmpty("temporal"); if (String.IsNullOrEmpty(m_UAModelDesignerProject.Name)) { m_UAModelDesignerProject.Name = Guid.NewGuid().ToString(); } if (String.IsNullOrEmpty(m_UAModelDesignerProject.CSVFileName)) { m_UAModelDesignerProject.CSVFileName = _def.CSVFileName; } if (String.IsNullOrEmpty(m_UAModelDesignerProject.BuildOutputDirectoryName)) { m_UAModelDesignerProject.BuildOutputDirectoryName = _def.BuildOutputDirectoryName; } string _CSVFileName = ReplaceTokenAndReturnFullPath(m_UAModelDesignerProject.CSVFileName, m_UAModelDesignerProject.Name, this.DefaultDirectory); string _OutputDirectory = ReplaceTokenAndReturnFullPath(m_UAModelDesignerProject.BuildOutputDirectoryName, m_UAModelDesignerProject.Name, this.DefaultDirectory); return(new ValueTuple <string, string>(_CSVFileName, _OutputDirectory)); }
internal static IProjectConfigurationManagement ImportModelDesign(ISolutionConfigurationManagement solution, IGraphicalUserInterface gui) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (gui == null) { throw new ArgumentNullException(nameof(gui)); } Tuple <OpcUaModelCompiler.ModelDesign, string> _modelDesign = TypeGenericConfigurationManagement <OpcUaModelCompiler.ModelDesign> .ReadConfiguration(gui, SetupFileDialog); if (_modelDesign.Item1 == null) { return(null); } UAModelDesignerProject uaModelDesignerProject = UAModelDesignerProject.CreateEmpty(Path.GetFileNameWithoutExtension(_modelDesign.Item2)); uaModelDesignerProject.FileName = CAS.CommServer.UA.ModelDesigner.Configuration.IO.RelativeFilePathsCalculator.TryComputeRelativePath(solution.DefaultDirectory, _modelDesign.Item2); return(new ProjectConfigurationManagement(false, uaModelDesignerProject, solution, _modelDesign, gui)); }
internal static IProjectConfigurationManagement ImportModelDesign(ISolutionConfigurationManagement solution, IGraphicalUserInterface gui, UAModelDesignerProject uaModelDesignerProject) { if (solution == null) { throw new ArgumentNullException(nameof(solution)); } if (gui == null) { throw new ArgumentNullException(nameof(gui)); } if (uaModelDesignerProject == null) { throw new ArgumentNullException(nameof(uaModelDesignerProject)); } string _filePath = Path.Combine(solution.DefaultDirectory, uaModelDesignerProject.FileName); Tuple <OpcUaModelCompiler.ModelDesign, string> _modelDesign = new Tuple <OpcUaModelCompiler.ModelDesign, string>(TypeGenericConfigurationManagement <OpcUaModelCompiler.ModelDesign> .ReadConfiguration(Path.Combine(solution.DefaultDirectory, uaModelDesignerProject.FileName), gui), _filePath); return(new ProjectConfigurationManagement(false, uaModelDesignerProject, solution, _modelDesign, gui)); }