Esempio n. 1
0
        public void PROPVARIANTOtherPropsTest(VARTYPE vt, string prop)
        {
            object value;

            Assert.That(() =>
            {
                if ((value = GetSampleData(vt)) == null)
                {
                    return;
                }
                using (var pv = new PROPVARIANT(value, (VarEnum)vt))
                {
                    var isa = value.GetType().IsArray;
                    Assert.That(pv.vt, Is.EqualTo(vt));
                    if (isa)
                    {
                        Assert.That(pv.Value, Is.EquivalentTo((IEnumerable)value));
                    }
                    else
                    {
                        Assert.That(pv.Value, Is.EqualTo(value));
                    }
                    var pi = pv.GetType().GetProperty(prop);
                    Assert.That(pi, Is.Not.Null);
                    if (isa)
                    {
                        Assert.That(pi.GetValue(pv), Is.EquivalentTo((IEnumerable)value));
                    }
                    else
                    {
                        Assert.That(pi.GetValue(pv), Is.EqualTo(value));
                    }
                }
            }, Throws.Nothing);
        }
Esempio n. 2
0
 public void PROPVARIANTPropsTest(object value, VARTYPE vt, string prop)
 {
     using (var pv = new PROPVARIANT(value))
     {
         Assert.That(pv.vt, Is.EqualTo(vt));
         Assert.That(pv.Value, Is.EqualTo(value));
         var pi = pv.GetType().GetProperty(prop);
         Assert.That(pi, Is.Not.Null);
         Assert.That(pi.GetValue(pv), Is.EqualTo(value));
     }
 }
Esempio n. 3
0
        public void PROPVARIANTEnumPropsTest(object value, VARTYPE vt, string prop)
        {
            const int len = 5;
            var       arr = Array.CreateInstance(value.GetType(), len);

            for (var i = 0; i < len; i++)
            {
                arr.SetValue(value, i);
            }
            using (var pv = new PROPVARIANT(arr))
            {
                Assert.That(pv.vt, Is.EqualTo(vt | VARTYPE.VT_VECTOR));
                Assert.That(pv.Value, Is.EquivalentTo(arr));
                var pi = pv.GetType().GetProperty(prop);
                Assert.That(pi, Is.Not.Null);
                Assert.That(pi.GetValue(pv), Is.EquivalentTo(arr));
            }
        }