示例#1
0
        public void Test_PropertyDefinitionListActivation()
        {
            PropertyDefinition propDef = new PropertyDefinition(
                "Events",
                typeof(IList <Event>));

            Assert.IsTrue(propDef.Type == typeof(IList <Event>));
            Assert.IsTrue(propDef.IsEnumerable);
            Assert.IsTrue(propDef.IEnumerableUnderlyingType == typeof(Event));
            object observable = propDef.ActivateObservableList(null);

            Assert.IsInstanceOfType(observable, typeof(ObservableCollection <Event>));

            IList <Event> outlookItems = new List <Event>();

            outlookItems.Add(new Event());
            observable = propDef.ActivateObservableList(outlookItems);
            Assert.IsInstanceOfType(observable, typeof(ObservableCollection <Event>));

            ObservableCollection <Event> observableCollection = (ObservableCollection <Event>)observable;

            Assert.IsTrue(observableCollection.Count == 1);

            IList <object> eventCollection = propDef.ActivateList(observableCollection);

            Assert.IsTrue(eventCollection.Count == 1);
        }