示例#1
0
        public void PreventsRegistrationWithDifferentTypes_2()
        {
            var propertyBag = new TypedPropertyBag();

            propertyBag.SetValue("Int", 42);
            ExceptionTester.CallMethodAndExpectException <InvalidCastException>(() => propertyBag.SetValue("Int", new object()));
        }
示例#2
0
        public void PreventsRegistrationWithNullValue()
        {
            var propertyBag = new TypedPropertyBag();

            propertyBag.SetValue("Int", 42);
            ExceptionTester.CallMethodAndExpectException <InvalidOperationException>(() => propertyBag.SetValue("Int", (object)null));
        }
示例#3
0
        public void AutomaticallyCastsObjectsToRightTypesIfPossible()
        {
            var propertyBag = new TypedPropertyBag();

            propertyBag.SetValue("Int", 42);
            propertyBag.SetValue("Int", (object)52);

            Assert.AreEqual(52, propertyBag.GetValue("Int", 0));
        }