示例#1
0
        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);
        }
示例#2
0
 internal void Save()
 {
     m_ProjectConfigurationManager.Save(Model.GetModel());
 }