Beispiel #1
0
        private static void IsPublicPropertiesSerialized(object o, string s)
        {
            if (o == null)
            {
                throw new ArgumentNullException(nameof(o));
            }
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            Assert.IsNotNull(o);
            Assert.IsNotNull(s);
            var properties = GetClass.Properties(o.GetType());

            foreach (var p in properties)
            {
                if (!p.CanRead)
                {
                    continue;
                }
                if (!p.CanWrite)
                {
                    continue;
                }
                var n = p.Name;
                Assert.IsTrue(s.Contains(n), n);
            }
        }
Beispiel #2
0
        private static void isPublicPropertiesSerialized(object o, string s)
        {
            Assert.IsNotNull(o);
            Assert.IsNotNull(s);
            var properties = GetClass.Properties(o.GetType());

            foreach (var p in properties)
            {
                if (!p.CanRead)
                {
                    continue;
                }
                if (!p.CanWrite)
                {
                    continue;
                }
                if (p.GetGetMethod(false) == null)
                {
                    continue;
                }
                if (p.GetSetMethod(false) == null)
                {
                    continue;
                }
                var n = p.Name;
                Assert.IsTrue(s.Contains(n), n);
            }
        }
Beispiel #3
0
        [TestMethod] public void PropertiesTest()
        {
            var a = GetClass.Properties(typeof(TestClass));

            Assert.IsNotNull(a);
            Assert.IsInstanceOfType(a, typeof(List <PropertyInfo>));
            Assert.AreEqual(1, a.Count);
            Assert.AreEqual("F", a[0].Name);
        }
        private static void setValuesForProperties(object o)
        {
            if (o is null)
            {
                return;
            }
            var t          = o.GetType();
            var properties = GetClass.Properties(t);

            foreach (var p in properties)
            {
                if (!p.CanWrite)
                {
                    continue;
                }
                if (p.PropertyType.Name == t.Name)
                {
                    continue;
                }
                var v = GetRandom.Value(p.PropertyType);
                p.SetValue(o, v);
            }
        }