Esempio n. 1
0
        public void GetPropertiesValues_is_correct()
        {
            const int    number = 12;
            const string text   = "test_text";
            var          obj    = new TypeWithCtorAndProps(number, text);
            var          type   = obj.GetType();

            var props = type.GetPropertiesValues(obj);

            props.Count.ShouldBe(2);
            props[nameof(TypeWithCtorAndProps.Number)].ShouldBe(number);
            props[nameof(TypeWithCtorAndProps.Text)].ShouldBe(text);
        }
Esempio n. 2
0
        public void SetPropertyByName_is_correct()
        {
            const int    number = 12;
            const string text   = "test_text";
            var          obj    = new TypeWithCtorAndProps(number, text);
            var          type   = obj.GetType();

            type.SetPropertyValueByName(obj, nameof(TypeWithCtorAndProps.Number), number * 2);
            type.SetPropertyValueByName(obj, nameof(TypeWithCtorAndProps.Text), text + text);

            obj.Number.ShouldBe(24);
            obj.Text.ShouldBe("test_texttest_text");
        }
Esempio n. 3
0
        public void GetPropertyByName_is_correct()
        {
            const int    number = 12;
            const string text   = "test_text";
            var          obj    = new TypeWithCtorAndProps(number, text);
            var          type   = obj.GetType();

            type
            .GetPropertyValueByName(obj, nameof(TypeWithCtorAndProps.Number))
            .ShouldBe(number);

            type
            .GetPropertyValueByName(obj, nameof(TypeWithCtorAndProps.Text))
            .ShouldBe(text);
        }