Ejemplo n.º 1
0
        public void SaveTest()
        {
            //preparation
            Mock <IProjectConfigurationManagement> _projectConfigurationMock = new Mock <IProjectConfigurationManagement>();
            Mock <OPCFModelDesign> _OPCFModelDesignMock = new Mock <OPCFModelDesign>();

            _projectConfigurationMock.SetupGet <OPCFModelDesign>(x => x.ModelDesign).Returns(_OPCFModelDesignMock.Object);
            _projectConfigurationMock.SetupGet <string>(x => x.Name).Returns("EFFF0C05 - 8406 - 4AD9 - 8725 - F00FC8295327");
            Mock <BaseTreeNode> _parentMock = new Mock <BaseTreeNode>("ParentBaseNode");

            _parentMock.SetupGet <string[]>(x => x.AvailiableNamespaces).Returns(new List <string>()
            {
                "ns1", "ns2"
            }.ToArray());
            _parentMock.Setup(x => x.GetTargetNamespace()).Returns("GetTargetNamespace");
            //create object under test
            ProjectTreeNode _newItem = new ProjectTreeNode(_projectConfigurationMock.Object)
            {
                Parent = _parentMock.Object
            };

            _newItem.Save();

            _projectConfigurationMock.Verify(x => x.Save(It.IsAny <OPCFModelDesign>()), Times.Once);
        }
Ejemplo n.º 2
0
        public void GetTargetNamespaceTest()
        {
            Mock <ISolutionDirectoryPathManagement> _directory = new Mock <ISolutionDirectoryPathManagement>();
            string _solutionDir = Path.Combine(Directory.GetCurrentDirectory(), "Temp");

            Directory.CreateDirectory(_solutionDir);
            _directory.SetupGet(x => x.BaseDirectory).Returns(_solutionDir);
            ProjectTreeNode _emptyModel = ProjectTreeNode.CreateNewModel(_directory.Object);

            _emptyModel.Save();
            string _expectedModelFileName = Path.Combine(_solutionDir, _emptyModel.FileName);

            Assert.IsTrue(File.Exists(_expectedModelFileName), _expectedModelFileName);
        }