Beispiel #1
0
 /// <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="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, ISolutionConfigurationManagement solution, EventHandler <EventArgs> OnChangeHandler, Action <LibraryTreeNode> creteLibraryTreeNode) :
     base(null, solution == null ? Guid.NewGuid().ToString() : solution.Name)
 {
     MessageBoxHandling = messageBoxHandling ?? throw new ArgumentNullException(nameof(messageBoxHandling));
     m_ISolutionConfigurationManagement = solution ?? throw new ArgumentNullException(nameof(solution), $"In constructor {nameof(SolutionTreeNode)} this argument must not be null.");
     Server.OnConfigurationChanged     += new EventHandler <UAServerConfigurationEventArgs>(Server_OnConfigurationChanged);
     //TODO OnDataChanged += OnChangeHandler;
     //TODO OnNameChanged += new EventHandler(configuration_OnNameChanged);
     AddProjectsNodes(solution.Projects);
     AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 325542572, "Creating Libraries");
     SolutionRoot = this;
     LibraryRoot.AddNodes(creteLibraryTreeNode);
 }
Beispiel #2
0
        public void ConstructorTest()
        {
            Mock <IGraphicalUserInterface>          _IGraphicalUserInterface = new Mock <IGraphicalUserInterface>();
            Mock <ISolutionConfigurationManagement> _solutionManagement      = new Mock <ISolutionConfigurationManagement>();

            _solutionManagement.SetupGet <string>(x => x.Name).Returns("Name");
            ServerSelector _serverSelector = new ServerSelector(_IGraphicalUserInterface.Object, _solutionManagement.Object, "", "");

            _solutionManagement.SetupGet <ServerSelector>(x => x.ServerSelector).Returns(_serverSelector);
            Mock <IMessageBoxHandling> _IMessageBoxHandlingMock = new Mock <IMessageBoxHandling>();
            int _librariesCallCounter = 0;

            Assert.ThrowsException <ArgumentNullException>(() => new SolutionTreeNode(null, _solutionManagement.Object, (x, y) => { Assert.Fail(); }, z => _librariesCallCounter++));
            Assert.ThrowsException <ArgumentNullException>(() => new SolutionTreeNode(_IMessageBoxHandlingMock.Object, null, (x, y) => { Assert.Fail(); }, z => _librariesCallCounter++));
            SolutionTreeNode _instanceUnderTest = new SolutionTreeNode(_IMessageBoxHandlingMock.Object, _solutionManagement.Object, (x, y) => { Assert.Fail(); }, z => _librariesCallCounter++);
            //_IMessageBoxHandlingMock
            IMessageBoxHandling _assignedIMessageBoxHandling = null;

            _instanceUnderTest.GetMessageBoxHandling(x => _assignedIMessageBoxHandling = x);
            Assert.IsNotNull(_assignedIMessageBoxHandling);
            Assert.AreSame(_IMessageBoxHandlingMock.Object, _assignedIMessageBoxHandling);
            Assert.AreEqual <int>(0, _IMessageBoxHandlingMock.Invocations.Count);
            //State
            Assert.ThrowsException <NullReferenceException>(() => _instanceUnderTest.AvailiableNamespaces);
            Assert.AreEqual <int>(0, _instanceUnderTest.Count);
            Assert.IsNotNull(_instanceUnderTest.ErrorList);
            Assert.AreEqual <int>(0, _instanceUnderTest.ErrorList.Count);
            Assert.AreEqual <string>("", _instanceUnderTest.HelpTopicName);
            Assert.AreSame(_solutionManagement.Object, _instanceUnderTest.HomeDirectory);
            Assert.IsFalse(_instanceUnderTest.IsReadOnly);
            Assert.AreEqual <string>(_solutionManagement.Object.Name, _instanceUnderTest.Name);
            Assert.AreEqual <NodeClassesEnum>(NodeClassesEnum.None, _instanceUnderTest.NodeClass);
            Assert.AreEqual <NodeTypeEnum>(NodeTypeEnum.SolutionNode, _instanceUnderTest.NodeType);
            Assert.IsNull(_instanceUnderTest.Parent);
            Assert.IsNotNull(_instanceUnderTest.Server);
            Assert.AreSame(_serverSelector, _instanceUnderTest.Server);
            Assert.IsNotNull(_instanceUnderTest.SymbolicName);
            Assert.AreEqual <string>(_solutionManagement.Object.Name, _instanceUnderTest.Text);
            Assert.IsNull(_instanceUnderTest.ToolTipText);
            Assert.IsNotNull(_instanceUnderTest.Wrapper);
            Assert.IsInstanceOfType(_instanceUnderTest.Wrapper, typeof(Wrappers4ProperyGrid.UAModelDesignerSolutionWrapper));
            Assert.IsNotNull(_instanceUnderTest.Wrapper4PropertyGrid);
            Assert.IsInstanceOfType(_instanceUnderTest.Wrapper4PropertyGrid, typeof(Wrappers4ProperyGrid.UAModelDesignerSolutionWrapper));
            Libraries _libraries = null;

            _instanceUnderTest.GetLibraries(x => _libraries = x);
            Assert.IsNotNull(_libraries);
            Assert.AreEqual <int>(1, _libraries.Count);
            Assert.AreEqual <int>(1, _librariesCallCounter);
        }
Beispiel #3
0
 /// <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);
 }
Beispiel #4
0
 /// <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);
        }