示例#1
0
        internal static MI_Instance CreateBasicSerializableTestInstance()
        {
            MI_Instance toSerialize;
            MI_Result   res = StaticFixtures.Application.NewInstance("TestInstance", null, out toSerialize);

            MIAssert.Succeeded(res);
            MI_Value valueToSerialize = MI_Value.NewDirectPtr();

            valueToSerialize.String = "Test string";
            res = toSerialize.AddElement("string", valueToSerialize, MI_Type.MI_STRING, MI_Flags.None);
            MIAssert.Succeeded(res);

            return(toSerialize);
        }
示例#2
0
        public void CanGetPrimitivePropertyOfInstance()
        {
            MI_Value primitiveValue = MI_Value.NewDirectPtr();

            primitiveValue.Uint8 = 42;
            var res = this.instance.AddElement("Foo", primitiveValue, MI_Type.MI_UINT8, MI_Flags.None);

            MIAssert.Succeeded(res);

            var cimInstance = new CimInstance(this.instance);
            var properties  = cimInstance.CimInstanceProperties;

            Assert.Equal(1, properties.Count, "Expect 1 property");
            var property = properties["Foo"];

            Assert.NotNull(property, "Expect property object to be non-null");
            Assert.Equal(CimType.UInt8, property.CimType, "Expect type to roundtrip correctly");
            Assert.NotEqual(CimFlags.NullValue, property.Flags & CimFlags.NullValue, "Expect to not get null flags");
            Assert.Equal <byte>(42, (byte)property.Value, "Expect property value to match original value");
        }