Example #1
0
        public void GetPropertyValueObject()
        {
            int    number   = 7;
            string txt      = "vrk ptv";
            string typeText = "Test";

            SomeDemoObject obj = new SomeDemoObject()
            {
                Integer = number,
                String  = txt,
                Type    = typeText
            };

            obj.SomeList.Add("ptv");
            obj.SomeList.Add("vrk");

            obj.GetPropertyObjectValue("Integer").Should().Be(number);
            obj.GetPropertyObjectValue("String").Should().Be(txt);
            obj.GetPropertyObjectValue("Type").Should().Be(typeText);

            IList <string> theList = obj.GetPropertyObjectValue("SomeList") as IList <string>;

            theList.Should().NotBeNullOrEmpty();
            theList.Count.Should().Be(2);
        }
Example #2
0
        public void GetPropertyValueObjectPropertyNameIsNullShouldThrow()
        {
            SomeDemoObject obj = new SomeDemoObject()
            {
                Integer = 8,
                String  = "vrk ptv",
                Type    = "Demo"
            };

            obj.SomeList.Add("ptv");
            obj.SomeList.Add("vrk");

            // extension should throw an ArgumentNullException
            Action act = () => obj.GetPropertyObjectValue(null);

            act.ShouldThrowExactly <ArgumentNullException>("Property name is null.");
        }
Example #3
0
        public void GetPropertyValueObjectInvalidPropertyNameShouldThrow(string propertyName)
        {
            SomeDemoObject obj = new SomeDemoObject()
            {
                Integer = 8,
                String  = "vrk ptv",
                Type    = "Demo"
            };

            obj.SomeList.Add("ptv");
            obj.SomeList.Add("vrk");

            // extension should throw an argumenexception when a known invalid propertyname is passed
            // why? because otherwise the caller doesn't know that the property is missing from the object
            Action act = () => obj.GetPropertyObjectValue(propertyName);

            act.ShouldThrowExactly <ArgumentException>("Known invalid property name.");
        }