public void CreateNewTest() { Mock <ISolutionConfigurationManagement> _solutionMock = new Mock <ISolutionConfigurationManagement>(); _solutionMock.SetupGet(x => x.DefaultDirectory).Returns(@"C:\a\b\c\"); _solutionMock.Setup(x => x.DefaultFileName); Mock <IFileDialog> _IFileDialogMock = new Mock <IFileDialog>(); _IFileDialogMock.SetupGet(x => x.FileName).Throws <ApplicationException>(); _IFileDialogMock.SetupGet(x => x.InitialDirectory).Throws <ApplicationException>(); _IFileDialogMock.Setup(x => x.Dispose()); _IFileDialogMock.Setup(x => x.ShowDialog()); IProjectConfigurationManagement _newItem = ProjectConfigurationManagement.CreateNew(_solutionMock.Object, new GraphicalUserInterface(_IFileDialogMock.Object), "projectName"); Assert.IsTrue(((ProjectConfigurationManagement)_newItem).ChangesArePresent); Assert.IsNotNull(_newItem.ModelDesign); Assert.AreEqual <string>("projectName", _newItem.Name); Assert.AreEqual <string>(@"C:\a\b\c", _newItem.DefaultDirectory); Assert.AreEqual <string>(@"C:\a\b\c\projectName.xml", _newItem.DefaultFileName); CheckConsistency(_newItem.UAModelDesignerProject); //_solutionMock _solutionMock.Verify(x => x.DefaultDirectory, Times.AtLeastOnce); _solutionMock.Verify(x => x.DefaultFileName, Times.Never); //_IFileDialogMock _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never); _IFileDialogMock.Verify(x => x.FileName, Times.Never); _IFileDialogMock.Verify(x => x.Filter, Times.Never); _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never); _IFileDialogMock.Verify(x => x.Title, Times.Never); _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Never); _IFileDialogMock.Verify(x => x.Dispose(), Times.Never); }
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.ImportModelDesign() { IProjectConfigurationManagement _newModel = ProjectConfigurationManagement.ImportModelDesign(this, base.GraphicalUserInterface); if (_newModel == null) { return; } AddProjectTCollection(_newModel); }
void ISolutionConfigurationManagement.NewModelDesign() { IProjectConfigurationManagement _newModel = ProjectConfigurationManagement.CreateNew(this, base.GraphicalUserInterface, m_UniqueNameGenerator.GenerateNewName()); if (_newModel == null) { throw new ApplicationException("New project must be created"); } AddProjectTCollection(_newModel); }
/// <summary> /// Imports the UANodeSet encapsulated by a new project. /// </summary> /// <param name="solutionPathProvider">The solution path provider.</param> /// <param name="traceEvent">The trace event.</param> /// <returns>ProjectTreeNode.</returns> void ISolutionConfigurationManagement.ImportNodeSet() { IProjectConfigurationManagement _newModel = ProjectConfigurationManagement.ImportNodeSet(this, base.GraphicalUserInterface, x => AssemblyTraceEvent.Log.TraceMessage(x, nameof(ISolutionConfigurationManagement.ImportNodeSet), 486245093)); if (_newModel == null) { return; } AddProjectTCollection(_newModel); }
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); }
public void SaveNewTest() { //TODO Creating new project the existing one should not be overridden #174 string _solutionPath = Path.Combine(Directory.GetCurrentDirectory(), "TestData"); Mock <ISolutionConfigurationManagement> _solutionMock = new Mock <ISolutionConfigurationManagement>(); _solutionMock.SetupGet(x => x.DefaultDirectory).Returns(_solutionPath); Mock <IFileDialog> _IFileDialogMock = new Mock <IFileDialog>(); Mock <IGraphicalUserInterface> _guiMock = new Mock <IGraphicalUserInterface>(); _guiMock.SetupGet(z => z.OpenFileDialogFunc).Returns(() => _IFileDialogMock.Object); _guiMock.SetupSet(z => z.UseWaitCursor = It.IsAny <bool>()); IProjectConfigurationManagement _newItem = ProjectConfigurationManagement.CreateNew(_solutionMock.Object, _guiMock.Object, "projectName"); Assert.IsTrue(((ProjectConfigurationManagement)_newItem).ChangesArePresent); Assert.IsNotNull(_newItem.ModelDesign); Assert.AreEqual <string>("projectName", _newItem.Name); Assert.IsNotNull(_newItem.UAModelDesignerProject); _solutionMock.Verify(x => x.DefaultDirectory, Times.AtLeastOnce); _solutionMock.Verify(x => x.DefaultFileName, Times.Never); ModelDesign _modelDesign = new ModelDesign(); //test save _newItem.Save(_modelDesign); _solutionMock.Verify(x => x.DefaultDirectory, Times.AtLeastOnce); _solutionMock.Verify(x => x.DefaultFileName, Times.Never); _guiMock.VerifySet(x => x.UseWaitCursor = true, Times.Once); _guiMock.VerifySet(x => x.UseWaitCursor = false, Times.Once); Assert.IsTrue(File.Exists(Path.Combine(_solutionPath, "projectName.xml"))); //_IFileDialogMock _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never); _IFileDialogMock.Verify(x => x.FileName, Times.Never); _IFileDialogMock.Verify(x => x.Filter, Times.Never); _IFileDialogMock.Verify(x => x.InitialDirectory, Times.Never); _IFileDialogMock.Verify(x => x.Title, Times.Never); _IFileDialogMock.Verify(x => x.ShowDialog(), Times.Never); _IFileDialogMock.Verify(x => x.Dispose(), Times.Never); }
private void AddProjectTCollection(IProjectConfigurationManagement _newModel) { m_Projects.Add(_newModel); SolutionConfigurationManagementRoot.DefaultInstance.OnSolutionChanged(); }
private static readonly object m_BuildLockObject = new object(); // this object is used to prevent many code generator usage at the same time #endregion private #region constructors /// <summary> /// Initializes a new instance of the <see cref="ProjectTreeNode"/> encapsulating an existing UA model. /// </summary> /// <param name="solutionPath">The solution path.</param> /// <param name="projectDescription">The project description.</param> internal ProjectTreeNode(IProjectConfigurationManagement projectDescription) : base(null, projectDescription.Name) { m_ProjectConfigurationManager = projectDescription; Model = new ModelDesign(projectDescription.ModelDesign, false); Add(Model); }