Esempio n. 1
0
        public void ReadFails()
        {
            using (H5File hf = H5File.Open(demodata + "test_generic_read.h5", mode: "r"))
            {
                H5Group grp = hf.Root.SubGroup("my_group");

                Assert.Throws <KeyNotFoundException>(() => grp.GetAttribute("asdfawieryan"));
                Assert.Throws <KeyNotFoundException>(() => grp["float_1D"].GetAttribute("awxryan"));

                H5Attribute attr = grp.GetAttribute("group_attr");

                Assert.Throws <InvalidCastException>(() => attr.Read <float>());
                Assert.Throws <InvalidCastException>(() => attr.Read <string>());
                Assert.Throws <InvalidCastException>(() => attr.Read <long>());
            }
        }
Esempio n. 2
0
        public void Read()
        {
            using (H5File hf = H5File.Open(demodata + "test_generic_read.h5", mode: "r"))
            {
                H5Group grp = hf.Root.SubGroup("my_group");

                H5Attribute attr = grp.GetAttribute("group_attr");
                Assert.NotNull(attr);
                Assert.Equal(42, attr.Read <int>());

                attr = grp["float_1D"].GetAttribute("dataset_attr");
                Assert.NotNull(attr);
                Assert.Equal("a foo that bars", attr.Reads());
            }
        }