Esempio n. 1
0
            public void ReturnsRightPropertyValue()
            {
                _propertyBag.SetValue("StringProperty", "test");
                _propertyBag.SetValue("IntProperty", 1);

                Assert.AreEqual("test", _propertyBag.GetValue <string>("StringProperty"));
                Assert.AreEqual(1, _propertyBag.GetValue <int>("IntProperty"));
            }
Esempio n. 2
0
            public void ReturnsAllRegisteredProperties()
            {
                _propertyBag.SetValue("FirstProperty", 1);
                _propertyBag.SetValue("SecondProperty", "test");

                var allProperties = _propertyBag.GetAllNames().ToList();

                Assert.AreEqual(2, allProperties.Count);

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

                Assert.AreEqual("SecondProperty", allProperties[1]);
                //Assert.AreEqual("test", allProperties[1].Value);
            }
Esempio n. 3
0
        public void AllocProperties()
        {
            const int PropertyCount = 10;

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue <int>($"Int{i}", 0);
            }

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue <bool>($"Bool{i}", true);
            }

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue <object>($"Ref{i}", new object());
            }
        }
Esempio n. 4
0
        public void PropertyChanged()
        {
            for (int i = 0; i < 5000; i++)
            {
                for (var j = 0; j < PropertyCount; j++)
                {
                    _propertyBag.SetValue($"Int{j}", _random.Next(1000));
                }

                for (var j = 0; j < PropertyCount; j++)
                {
                    _propertyBag.SetValue($"Bool{j}", BoolValues[_random.Next(1000) % 2]);
                }

                for (var j = 0; j < PropertyCount; j++)
                {
                    _propertyBag.SetValue($"Ref{j}", new object());
                }
            }
        }
Esempio n. 5
0
        public void Setup()
        {
            _dictionaryFactory = Activator.CreateInstance(DictionaryFactoryType) as IDictionaryFactory;
            _propertyBag       = Activator.CreateInstance(ProperyBagType, _dictionaryFactory) as IPropertyBag;

            _random = new Random(1000);

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue($"Int{i}", 0);
            }

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue($"Bool{i}", false);
            }

            for (var i = 0; i < PropertyCount; i++)
            {
                _propertyBag.SetValue($"Ref{i}", new object());
            }
        }
Esempio n. 6
0
            public void ReturnsTrueForRegisteredPropertyName()
            {
                _propertyBag.SetValue("MyProperty", 1);

                Assert.IsTrue(_propertyBag.IsAvailable("MyProperty"));
            }
Esempio n. 7
0
 public void ThrowsArgumentExceptionForInvalidPropertyName()
 {
     ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => _propertyBag.SetValue <object>(null, null));
     ExceptionTester.CallMethodAndExpectException <ArgumentException>(() => _propertyBag.SetValue <object>(string.Empty, null));
 }