Пример #1
0
        public void InvokeOverloadedByTypeParameterizedPropertySetter()
        {
            var obj = new TestOverloadedByTypeParameterizedProperty(new [] {"a.txt"});
            var psObject = new PSObject(obj);
            var propertyInfo = psObject.Members.Single(m => m.Name == "FileNames") as PSParameterizedProperty;

            propertyInfo.InvokeSet("b.txt", "a.txt");

            Assert.AreEqual("b.txt", obj[1]);
        }
Пример #2
0
        public void ObjectWithOverloadedByTypeParameterizedProperty()
        {
            var obj = new TestOverloadedByTypeParameterizedProperty();
            var psObject = new PSObject(obj);

            var propertyInfo = psObject.Members.Single(m => m.Name == "FileNames") as PSParameterizedProperty;

            Assert.IsTrue(propertyInfo.IsGettable);
            Assert.IsTrue(propertyInfo.IsSettable);
            Assert.AreEqual("FileNames", propertyInfo.Name);
            Assert.AreEqual("System.String", propertyInfo.TypeNameOfValue);
            Assert.AreEqual(propertyInfo, propertyInfo.Value);
            Assert.AreEqual(2, propertyInfo.OverloadDefinitions.Count);
            Assert.AreEqual("string FileNames(int index) {get;set;}", propertyInfo.OverloadDefinitions[0]);
            Assert.AreEqual("string FileNames(string fileName) {get;set;}", propertyInfo.OverloadDefinitions[1]);
        }