Пример #1
0
        public unsafe void StringRoundTrip(string value)
        {
            byte *b = stackalloc byte[24];

            using (VARIANT v = new VARIANT((IntPtr)b, ownsHandle: true))
            {
                Marshal.GetNativeVariantForObject(value, v.DangerousGetHandle());
                v.VariantType.Should().Be(VARENUM.VT_BSTR);
                var data = v.GetData();
                data.Should().NotBeNull();
                data.Should().BeOfType <string>();
                data.Should().Be(value);
            }
        }
Пример #2
0
        public unsafe void DecimalRoundTrip(double value)
        {
            decimal d = new decimal(value);

            byte *b = stackalloc byte[24];

            using (VARIANT v = new VARIANT((IntPtr)b, ownsHandle: true))
            {
                Marshal.GetNativeVariantForObject(d, v.DangerousGetHandle());
                v.VariantType.Should().Be(VARENUM.VT_DECIMAL);
                var data = v.GetData();
                data.Should().NotBeNull();
                data.Should().BeOfType <decimal>();
                data.Should().Be(d);
            }
        }