Пример #1
0
            public void ThrowsArgumentExceptionForInvalidPropertyName()
            {
                var propertyBag = new PropertyBag();

                ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.GetPropertyValue<object>(null));
                ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.GetPropertyValue<object>(string.Empty));
            }
Пример #2
0
            public void ReturnsDefaultValueForNonRegisteredProperty()
            {
                var propertyBag = new PropertyBag();

                Assert.AreEqual(null, propertyBag.GetPropertyValue <string>("StringProperty"));
                Assert.AreEqual(0, propertyBag.GetPropertyValue <int>("IntProperty"));
            }
Пример #3
0
            public void ReturnsRightPropertyValue()
            {
                var propertyBag = new PropertyBag();

                propertyBag.SetPropertyValue("StringProperty", "test");
                propertyBag.SetPropertyValue("IntProperty", 1);

                Assert.AreEqual("test", propertyBag.GetPropertyValue <string>("StringProperty"));
                Assert.AreEqual(1, propertyBag.GetPropertyValue <int>("IntProperty"));
            }
Пример #4
0
            public void SetsPropertyCorrectly()
            {
                var propertyBag = new PropertyBag();

                propertyBag.SetPropertyValue("StringProperty", "A");
                Assert.AreEqual("A", propertyBag.GetPropertyValue <string>("StringProperty"));

                propertyBag.SetPropertyValue("StringProperty", "B");
                Assert.AreEqual("B", propertyBag.GetPropertyValue <string>("StringProperty"));
            }
Пример #5
0
            public void ReturnsDefaultValueForNonRegisteredProperty()
            {
                var propertyBag = new PropertyBag();

                Assert.AreEqual(null, propertyBag.GetPropertyValue<string>("StringProperty"));
                Assert.AreEqual(0, propertyBag.GetPropertyValue<int>("IntProperty"));
            }
Пример #6
0
            public void ReturnsRightPropertyValue()
            {
                var propertyBag = new PropertyBag();

                propertyBag.SetPropertyValue("StringProperty", "test");
                propertyBag.SetPropertyValue("IntProperty", 1);
                
                Assert.AreEqual("test", propertyBag.GetPropertyValue<string>("StringProperty"));
                Assert.AreEqual(1, propertyBag.GetPropertyValue<int>("IntProperty"));
            }
Пример #7
0
            public void SetsPropertyCorrectly()
            {
                var propertyBag = new PropertyBag();

                propertyBag.SetPropertyValue("StringProperty", "A");
                Assert.AreEqual("A", propertyBag.GetPropertyValue<string>("StringProperty"));

                propertyBag.SetPropertyValue("StringProperty", "B");
                Assert.AreEqual("B", propertyBag.GetPropertyValue<string>("StringProperty"));
            }
Пример #8
0
            public void ThrowsArgumentExceptionForInvalidPropertyName()
            {
                var propertyBag = new PropertyBag();

                ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => propertyBag.GetPropertyValue <object>(null));
                ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => propertyBag.GetPropertyValue <object>(string.Empty));
            }