Beispiel #1
0
            public void InjectReadonly()
            {
                string path = Path.Combine(demodata, "test_inject_readonly.h5");

                if (!File.Exists(path))
                {
                    using (H5File hf = H5File.Open(path, "x"))
                    {
                        var dset = hf.Root.CreateDataset("existing", 1, new long[] { 1 }, typeof(int));
                        // make sure, the file is closed properly:
                        dset.Dispose();
                    }
                }

                // first try: readonly file mode..
                using (var hf = H5File.Open(path, "r"))
                {
                    using (ReadOnlyObject myo = new ReadOnlyObject(hf.Root))
                    {
                        // ..dataset has been skipped:
                        Assert.Null(myo.readonli);

                        Assert.NotNull(myo.existing);
                    }
                }
            }
        public void ReadOnlyObjectEqualsSame()
        {
            var obj1 = new ReadOnlyObject(new Object());
            var obj2 = obj1;

            Assert.IsTrue(obj1 == obj2);
            Assert.IsFalse(obj1 != obj2);
            Assert.IsTrue(obj1.Equals(obj2));
            Assert.IsTrue(ReferenceEquals(obj1, obj2));
        }
        public void ReadOnlyObjectEqualsNull()
        {
            ReadOnlyObject obj = null;

            Assert.IsFalse(obj);
            Assert.IsTrue(obj == null);
            Assert.IsFalse(obj != null);
            Assert.IsTrue(ReferenceEquals(obj, null));

            obj = new ReadOnlyObject(new Object());

            // NOTE: This is Unity's intended implementation..
            Assert.IsFalse(obj);
            Assert.IsTrue(obj == null);
            Assert.IsFalse(obj != null);
            Assert.IsTrue(obj.Equals(null));
            Assert.IsFalse(ReferenceEquals(obj, null));
        }