IsSettable() public method

Gets whether the property is settable.
public IsSettable ( System.Management.Automation.PSAdaptedProperty adaptedProperty ) : bool
adaptedProperty System.Management.Automation.PSAdaptedProperty The property to check.
return bool
        public void RecordIsReadOnly()
        {
            var path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");
            using (var db = new Database(path, DatabaseOpenMode.ReadOnly))
            {
                var query = db.Tables["File"].SqlSelectString;
                using (var view = db.OpenView(query))
                {
                    view.Execute();
                    var columns = ViewManager.GetColumns(view);

                    // Fetch and test a single record.
                    using (var record = view.Fetch())
                    {
                        Assert.IsNotNull(record, "No record was found.");
                        var copy = new Record(record, columns);

                        var adapter = new RecordPropertyAdapter();
                        var property = adapter.GetProperty(copy, "FileName");
                        Assert.IsFalse(adapter.IsSettable(property), "The FileName property is settable.");

                        // Throws NotSupportedException.
                        adapter.SetPropertyValue(property, "test.wxs");
                    }
                }
            }
        }
Example #2
0
        public void RecordIsReadOnly()
        {
            var path = Path.Combine(this.TestContext.DeploymentDirectory, "Example.msi");

            using (var db = new Database(path, DatabaseOpenMode.ReadOnly))
            {
                var query = db.Tables["File"].SqlSelectString;
                using (var view = db.OpenView(query))
                {
                    view.Execute();
                    var columns = ViewManager.GetColumns(view);

                    // Fetch and test a single record.
                    using (var record = view.Fetch())
                    {
                        Assert.IsNotNull(record, "No record was found.");
                        var copy = new Record(record, columns);

                        var adapter  = new RecordPropertyAdapter();
                        var property = adapter.GetProperty(copy, "FileName");
                        Assert.IsFalse(adapter.IsSettable(property), "The FileName property is settable.");

                        // Throws NotSupportedException.
                        adapter.SetPropertyValue(property, "test.wxs");
                    }
                }
            }
        }