Пример #1
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"));
            }
Пример #2
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"));
            }
Пример #3
0
            public void ReturnsAllRegisteredPropertiesWithCorrectValues()
            {
                var propertyBag = new PropertyBag();
                propertyBag.SetPropertyValue("FirstProperty", 1);
                propertyBag.SetPropertyValue("SecondProperty", "test");

                var allProperties = propertyBag.GetAllProperties().ToList();

                Assert.AreEqual(2, allProperties.Count);

                Assert.AreEqual("FirstProperty", allProperties[0].Key);
                Assert.AreEqual(1, allProperties[0].Value);

                Assert.AreEqual("SecondProperty", allProperties[1].Key);
                Assert.AreEqual("test", allProperties[1].Value);
            }
Пример #4
0
            public void ReturnsTrueForRegisteredPropertyName()
            {
                var propertyBag = new PropertyBag();
                propertyBag.SetPropertyValue("MyProperty", 1);

                Assert.IsTrue(propertyBag.IsPropertyAvailable("MyProperty"));
            }
Пример #5
0
            public void ReturnsAllRegisteredPropertiesWithCorrectValues()
            {
                var propertyBag = new PropertyBag();

                propertyBag.SetPropertyValue("FirstProperty", 1);
                propertyBag.SetPropertyValue("SecondProperty", "test");

                var allProperties = propertyBag.GetAllProperties().ToList();

                Assert.AreEqual(2, allProperties.Count);

                Assert.AreEqual("FirstProperty", allProperties[0].Key);
                Assert.AreEqual(1, allProperties[0].Value);

                Assert.AreEqual("SecondProperty", allProperties[1].Key);
                Assert.AreEqual("test", allProperties[1].Value);
            }
Пример #6
0
            public void ReturnsTrueForRegisteredPropertyName()
            {
                var propertyBag = new PropertyBag();

                propertyBag.SetPropertyValue("MyProperty", 1);

                Assert.IsTrue(propertyBag.IsPropertyAvailable("MyProperty"));
            }
Пример #7
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"));
            }
Пример #8
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"));
            }
Пример #9
0
            public void ThrowsArgumentExceptionForInvalidPropertyName()
            {
                var propertyBag = new PropertyBag();

                ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.SetPropertyValue(null, null));
                ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.SetPropertyValue(string.Empty, null));
            }
Пример #10
0
            public void ThrowsArgumentExceptionForInvalidPropertyName()
            {
                var propertyBag = new PropertyBag();

                ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => propertyBag.SetPropertyValue(null, null));
                ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => propertyBag.SetPropertyValue(string.Empty, null));
            }