Ejemplo n.º 1
0
        private void CheckConsistency(ProjectTreeNode _newItem)
        {
            Assert.IsNotNull(_newItem);
            Assert.ThrowsException <NullReferenceException>(() => _newItem.AvailiableNamespaces);
            Assert.AreEqual <string>("$(ProjectFileName)", _newItem.BuildOutputDirectoryName);
            Assert.IsTrue(_newItem.BuildOutputDirectoryPath.StartsWith(@"C:\Model_"));
            Assert.AreEqual <int>(1, _newItem.Count);
            Assert.AreEqual <string>("$(ProjectFileName).csv", _newItem.CSVFileName);
            Assert.IsTrue(_newItem.CSVFilePath.StartsWith(@"C:\Model_"));
            Assert.AreEqual <string>(@".csv", Path.GetExtension(_newItem.CSVFilePath));
            Assert.IsNotNull(_newItem.ErrorList);
            Assert.AreEqual <int>(0, _newItem.ErrorList.Count);
            Assert.IsTrue(_newItem.FileName.StartsWith(@"Model_"), _newItem.FileName);
            Assert.IsTrue(_newItem.FileName.Contains(@".xml"), _newItem.FileName);
            string _absoluteModelFilePath = _newItem.CalculateEffectiveAbsoluteModelFilePath();

            Assert.IsTrue(_absoluteModelFilePath.StartsWith(@"C:\Model_"), _absoluteModelFilePath);
            Assert.IsTrue(_absoluteModelFilePath.Contains(@".xml"), _absoluteModelFilePath);
            Assert.AreEqual <string>(@"", _newItem.HelpTopicName);
            Assert.ThrowsException <NullReferenceException>(() => _newItem.GetTargetNamespace());
            Assert.IsNull(_newItem.Parent);
            Assert.IsNotNull(_newItem.SymbolicName);
            Assert.IsTrue(_newItem.Text.StartsWith(@"Model_"), _newItem.Text);
            Assert.IsTrue(String.IsNullOrEmpty(_newItem.ToolTipText));
            CheckConsistency(_newItem.UAModelDesignerProject);
            object _viewModel = _newItem.Wrapper;

            Assert.IsNotNull(_viewModel);
            Assert.AreSame(_viewModel, ViewModel.Instance);
            object _w4pg = _newItem.Wrapper4PropertyGrid;

            Assert.IsNotNull(_w4pg);
            Assert.AreSame(_w4pg, ViewModel.Instance);
        }
Ejemplo n.º 2
0
        public void CreateNewModelTest()
        {
            //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
            };

            //test consistency
            Assert.IsNotNull(_newItem.Parent);
            Assert.AreEqual <int>(2, _newItem.AvailiableNamespaces.Length);
            Assert.AreEqual <int>(1, _newItem.Count);
            Assert.IsNotNull(_newItem.ErrorList);
            Assert.AreEqual <int>(0, _newItem.ErrorList.Count);
            Assert.AreEqual <string>(@"", _newItem.HelpTopicName);
            Assert.AreEqual <string>("GetTargetNamespace", _newItem.GetTargetNamespace());
            Assert.IsNotNull(_newItem.SymbolicName);
            Assert.AreEqual <string>(@"EFFF0C05 - 8406 - 4AD9 - 8725 - F00FC8295327", _newItem.Text);
            Assert.IsTrue(String.IsNullOrEmpty(_newItem.ToolTipText));
            object _viewModel = _newItem.Wrapper;

            Assert.IsNotNull(_viewModel);
            Assert.AreSame(_viewModel, ViewModel.Instance);
            object _w4pg = _newItem.Wrapper4PropertyGrid;

            Assert.IsNotNull(_w4pg);
            Assert.AreSame(_w4pg, ViewModel.Instance);
            //test behavior
            _projectConfigurationMock.VerifyGet(x => x.ModelDesign, Times.Once);
            _projectConfigurationMock.VerifyGet(x => x.Name, Times.Once);
        }