Example #1
0
        public void WriteAndReadStructsWithDatetime()
        {
            string filename = Path.Combine(folder, "testCompounds.H5");

            try
            {
                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/test", wDataList);
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                var cmpList = Hdf5.ReadCompounds <WData>(fileId, "/test").ToArray();
                Hdf5.CloseFile(fileId);
                CollectionAssert.AreEqual(wDataList, cmpList);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
Example #2
0
        public void WriteAndReadStructsWithArray()
        {
            string filename = Path.Combine(folder, "testArrayCompounds.H5");

            try
            {
                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/test", responseList);
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                Responses[] cmpList = Hdf5.ReadCompounds <Responses>(fileId, "/test").ToArray();
                Hdf5.CloseFile(fileId);
                var isSame = responseList.Zip(cmpList, (r, c) =>
                {
                    return(r.MCID == c.MCID &&
                           r.PanelIdx == c.PanelIdx &&
                           r.ResponseValues.Zip(c.ResponseValues, (rr, cr) => rr == cr).All(v => v == true));
                });
                Assert.IsTrue(isSame.All(s => s == true));
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
Example #3
0
        public void WriteAndReadStructs()
        {
            string filename = Path.Combine(folder, "testCompoundsWithDifferentDisplayName.H5");
            Dictionary <string, List <string> > attributes = new Dictionary <string, List <string> >();

            try
            {
                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/test", wData2List, attributes);
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                var cmpList = Hdf5.ReadCompounds <WData2>(fileId, "/test", "").ToArray();
                Hdf5.CloseFile(fileId);
                CollectionAssert.AreEqual(wData2List, cmpList);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
Example #4
0
        public void WriteAndReadSystemEvent()
        {
            string             filename = Path.Combine(folder, "testCompounds.H5");
            List <SystemEvent> se       = new List <SystemEvent>();
            Dictionary <string, List <string> > attributes = new Dictionary <string, List <string> >();

            try
            {
                se.Add(new SystemEvent(5, "55", "3300000000000000000000000", "555555555555555555555555555555555"));
                se.Add(new SystemEvent(1, "255", "3d3000000000007777773", "ggggggggggggdf"));

                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/test", se, attributes);
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                var cmpList = Hdf5.ReadCompounds <SystemEvent>(fileId, "/test", "").ToArray();
                Hdf5.CloseFile(fileId);
                CollectionAssert.AreEqual(se, cmpList);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
Example #5
0
        // [TestMethod]
        public void WriteCompoundTest()
        {
            string filename = Path.Combine(folder, "WriteCompound.H5");

            try
            {
                var timestamp    = DateTimeOffset.Now.ToUnixTimeMilliseconds();
                var id           = Int32.MaxValue;
                var double_array = new[] { 10.0, 20, 30 };
                var name         = "test";
                var c            = new Compound(timestamp, id, double_array, name);
                var fileId       = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/Sample Data", new List <Compound>()
                {
                    c
                }, new Dictionary <string, List <string> >());
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }