Example #1
0
        public void ScanProperties()
        {
            // Arrange
            var scanner = new ReflectionPropertyScanner();

            // Act
            var result = scanner.Scan(typeof(ClassWithPropertyAndEvents)).ToArray();

            // Assert
            Assert.AreEqual(2, result.Length);
            Assert.IsTrue(result.Any(p => p.Path.Equals((PropertyPath)"property")));
            Assert.IsTrue(result.Any(p => p.Path.Equals((PropertyPath) new[] { "second", "property" })));
        }
Example #2
0
        public void ValueIsSetAndEventIsRaised()
        {
            // Arrange
            var    scanner  = new ReflectionPropertyScanner();
            object newValue = null;
            var    property = scanner.Scan(typeof(ClassWithPropertyAndEvents))
                              .FirstOrDefault(p => Equals(p.Path, (PropertyPath)"property"));
            var ob = new ClassWithPropertyAndEvents();

            ob.Property = "banaan";
            property.SetObject(ob);
            property.ValueChanged += (sender, e) => newValue = e.NewValue;

            // Act
            property.TrySetValue("fdsa");

            // Assert
            Assert.AreEqual("fdsa", ob.Property);
            Assert.AreEqual("fdsa", newValue);
        }