Esempio n. 1
0
        public bool TestOpaque()
        {
            NcFile       file       = null;
            NcVar        var        = null;
            NcDim        dim        = null;
            NcType       type       = null;
            NcOpaqueType opaqueType = null;

            byte[] opaqueBuffer = new byte[32];
            byte[] readBuffer   = new byte[32];
            for (int i = 0; i < 32; i++)
            {
                opaqueBuffer[i] = (byte)i;
            }

            try {
                file       = TestHelper.NewFile(filePath);
                type       = file.AddOpaqueType("opaque", 32);
                opaqueType = new NcOpaqueType(type);

                Assert.Equals(type.GetTypeClass(), NcTypeEnum.NC_OPAQUE);
                Assert.Equals(opaqueType.GetTypeSize(), 32);

                dim = file.AddDim("time", 1);
                var = file.AddVar("opaqueVar", opaqueType, dim);
                int iLen = 0;
                var.PutVar(new Int32[] { 0 }, opaqueBuffer);
                iLen = var.GetVar(new Int32[] { 0 }, readBuffer);
                Assert.Equals(iLen, 32);
                for (int i = 0; i < 32; i++)
                {
                    Assert.Equals(readBuffer[i], opaqueBuffer[i]);
                }
            } finally {
                file.Close();
            }
            CheckDelete(filePath);
            return(true);
        }