public void ReadConfigurationTest() { UAModelDesignerSolution _configuration = XmlFile.ReadXmlFile <UAModelDesignerSolution>(m_Path); Assert.IsNotNull(_configuration); Assert.AreEqual <string>("Boiler Example Solution", _configuration.Name); Assert.AreEqual <int>(2, _configuration.Projects.Length); Assert.IsNotNull(_configuration.ServerDetails); Assert.AreEqual <string>(@"CAS.CommServer.UA.ConfigurationEditor.ServerConfiguration.dll", _configuration.ServerDetails.codebase); Assert.AreEqual <string>(@"DemoConfiguration\BoilerExample.uasconfig", _configuration.ServerDetails.configuration); }
/// <summary> /// Initializes a new instance of the <see cref="SolutionTreeNode" /> class. /// </summary> /// <param name="messageBoxHandling">The Message Box instance to provide messages on the screen.</param> /// <param name="solution">The configuration.</param> /// <param name="solutionPath">The solution path.</param> /// <param name="OnChangeHandler">The on change handler.</param> /// <param name="creteLibraryTreeNode">The call back to create <see cref="LibraryTreeNode"/>.</param> /// <exception cref="ArgumentNullException">configuration /// or /// messageBoxHandling</exception> internal SolutionTreeNode(IMessageBoxHandling messageBoxHandling, UAModelDesignerSolution solution, string solutionPath, EventHandler <EventArgs> OnChangeHandler, Action <LibraryTreeNode> creteLibraryTreeNode) : base(null, solution == null ? Guid.NewGuid().ToString() : solution.Name) { MessageBoxHandling = messageBoxHandling ?? throw new ArgumentNullException(nameof(messageBoxHandling)); HomeDirectory = solutionPath; if (solution.ServerDetails == null) { solution.ServerDetails = UAModelDesignerSolutionServerDetails.CreateEmptyInstance(); } Server = new ServerSelector(new GraphicalUserInterface(), solutionPath, solution.ServerDetails.codebase, solution.ServerDetails.configuration); Server.OnConfigurationChanged += new EventHandler <UAServerConfigurationEventArgs>(Server_OnConfigurationChanged); //TODO OnDataChanged += OnChangeHandler; //TODO OnNameChanged += new EventHandler(configuration_OnNameChanged); AddProjectsNodes(solution.Projects); BaseDirectoryHelper.Instance.SetBaseDirectoryProvider(this); SolutionRoot = this; LibraryRoot.AddNodes(creteLibraryTreeNode); }
/// <summary> /// Initializes a new instance of the <see cref="SolutionTreeNode" /> class. /// </summary> /// <param name="messageBoxHandling">The Message Box instance to provide messages on the screen.</param> /// <param name="solution">The configuration.</param> /// <param name="solutionPath">The solution path.</param> /// <param name="OnChangeHandler">The on change handler.</param> /// <param name="creteLibraryTreeNode">The call back to create <see cref="LibraryTreeNode"/>.</param> /// <exception cref="ArgumentNullException">configuration /// or /// messageBoxHandling</exception> internal SolutionTreeNode(IMessageBoxHandling messageBoxHandling, UAModelDesignerSolution solution, string solutionPath, EventHandler <EventArgs> OnChangeHandler, Action <LibraryTreeNode> creteLibraryTreeNode) : base(null, solution == null ? Guid.NewGuid().ToString() : solution.Name) { MessageBoxHandling = messageBoxHandling ?? throw new ArgumentNullException(nameof(messageBoxHandling)); m_PathManagement.SetNewPath(solutionPath); if (solution == null) { throw new ArgumentNullException(nameof(solution), $"In constructor {nameof(SolutionTreeNode)} this argument must not be null."); } if (solution.ServerDetails == null) { solution.ServerDetails = UAModelDesignerSolutionServerDetails.CreateEmptyInstance(); } Server = new ServerSelector(new GraphicalUserInterface(), m_PathManagement, solution.ServerDetails.codebase, solution.ServerDetails.configuration); Server.OnConfigurationChanged += new EventHandler <UAServerConfigurationEventArgs>(Server_OnConfigurationChanged); //TODO OnDataChanged += OnChangeHandler; //TODO OnNameChanged += new EventHandler(configuration_OnNameChanged); AddProjectsNodes(solution.Projects); SolutionRoot = this; LibraryRoot.AddNodes(creteLibraryTreeNode); }
public void ConstructorTest() { Mock <IMessageBoxHandling> _IMessageBoxHandlingMock = new Mock <IMessageBoxHandling>(); UAModelDesignerSolution _solution = UAModelDesignerSolution.CreateEmptyModel(); int _librariesCallCounter = 0; SolutionTreeNode _stn = new SolutionTreeNode(_IMessageBoxHandlingMock.Object, _solution, String.Empty, (x, y) => { Assert.Fail(); }, z => _librariesCallCounter++); //_IMessageBoxHandlingMock IMessageBoxHandling _assignedIMessageBoxHandling = null; _stn.GetMessageBoxHandling(x => _assignedIMessageBoxHandling = x); Assert.IsNotNull(_assignedIMessageBoxHandling); Assert.AreSame(_IMessageBoxHandlingMock.Object, _assignedIMessageBoxHandling); Assert.AreEqual <int>(0, _IMessageBoxHandlingMock.Invocations.Count); //State Assert.ThrowsException <NullReferenceException>(() => _stn.AvailiableNamespaces); Assert.AreEqual <int>(0, _stn.Count); Assert.IsNotNull(_stn.ErrorList); Assert.AreEqual <int>(0, _stn.ErrorList.Count); Assert.AreEqual <string>("", _stn.HelpTopicName); Assert.AreEqual <string>("", _stn.HomeDirectory); Assert.IsFalse(_stn.IsReadOnly); Assert.AreEqual <string>(_solution.Name, _stn.Name); Assert.AreEqual <NodeClassesEnum>(NodeClassesEnum.None, _stn.NodeClass); Assert.AreEqual <NodeTypeEnum>(NodeTypeEnum.SolutionNode, _stn.NodeType); Assert.IsNull(_stn.Parent); Assert.IsNotNull(_stn.Server); Assert.IsNotNull(_stn.SymbolicName); Assert.AreEqual <string>(_solution.Name, _stn.Text); Assert.IsNull(_stn.ToolTipText); Assert.IsNotNull(_stn.Wrapper); Assert.IsInstanceOfType(_stn.Wrapper, typeof(Wrappers4ProperyGrid.UAModelDesignerSolutionWrapper)); Assert.IsNotNull(_stn.Wrapper4PropertyGrid); Assert.IsInstanceOfType(_stn.Wrapper4PropertyGrid, typeof(Wrappers4ProperyGrid.UAModelDesignerSolutionWrapper)); Libraries _libraries = null; _stn.GetLibraries(x => _libraries = x); Assert.IsNotNull(_libraries); Assert.AreEqual <int>(1, _libraries.Count); Assert.AreEqual <int>(1, _librariesCallCounter); }
internal static void OpenExisting(string solutionFileName, IGraphicalUserInterface gui) { AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 234587501, $"Opening an existing solution captured in the file {solutionFileName} of the {nameof(SolutionConfigurationManagement)}"); if ((DefaultInstance.CurrentConfiguration != null) && !DefaultInstance.CurrentConfiguration.TestIfChangesArePresentDisplayWindowAndReturnTrueIfShouldBeContinued()) { return; } Tuple <UAModelDesignerSolution, string> _solution = null; bool _ChangesArePresent = false; try { if (String.IsNullOrEmpty(solutionFileName) || !File.Exists(solutionFileName)) { if (DefaultInstance.CurrentConfiguration != null) { _solution = SolutionConfigurationManagement.ReadConfiguration(gui, SolutionConfigurationManagement.SetupFileDialog); if (_solution == null) { return; } } else { string _defPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UAModelDesignerSolution"); _solution = new Tuple <UAModelDesignerSolution, string>(UAModelDesignerSolution.CreateEmptyModel(m_UniqueNameGenerator.GenerateNewName()), _defPath); _ChangesArePresent = true; } } else { solutionFileName = Path.GetFullPath(solutionFileName); _solution = new Tuple <UAModelDesignerSolution, string>(SolutionConfigurationManagement.ReadConfiguration(solutionFileName, gui), solutionFileName); } if (_solution.Item1.ServerDetails == null) { _solution.Item1.ServerDetails = UAModelDesignerSolutionServerDetails.CreateEmptyInstance(); } ISolutionConfigurationManagement _newSolution = new SolutionConfigurationManagement(_solution, _ChangesArePresent, gui); DefaultInstance.OnSolutionChanged(_newSolution); return; } catch (Exception ex) { string _tmp = "Cannot initialize {0} described by {1} because of exception: {2}."; AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Critical, 234587502, string.Format(_tmp, typeof(SolutionConfigurationManagement).FullName, _solution.Item2, ex.Message)); throw; } }
internal static void NewSoliution(IGraphicalUserInterface gui) { AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 234587504, $"New instance of the {nameof(SolutionConfigurationManagement)} is required"); if ((DefaultInstance.CurrentConfiguration != null) && (!DefaultInstance.CurrentConfiguration.TestIfChangesArePresentDisplayWindowAndReturnTrueIfShouldBeContinued())) { return; } AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 234587503, $"Creating new instance of the {nameof(SolutionConfigurationManagement)}"); string _defPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UAModelDesignerSolution"); SolutionConfigurationManagement _newSolution = new SolutionConfigurationManagement(new Tuple <UAModelDesignerSolution, string>(UAModelDesignerSolution.CreateEmptyModel(m_UniqueNameGenerator.GenerateNewName()), _defPath), true, gui); DefaultInstance.OnSolutionChanged(_newSolution); return; }
public AfterSolutionChangeEventArgs(UAModelDesignerSolution solution) { Solution = solution; }