Exemple #1
0
        public void InsertZeroLength()
        {
            if (Dialect is Oracle8iDialect)
            {
                Assert.Ignore("Certain drivers (ie - Oralce) don't handle writing and reading byte[0]");
            }
            BinaryClass bcBinary = new BinaryClass();

            bcBinary.Id = 1;

            bcBinary.DefaultSize = new byte[0];
            bcBinary.WithSize    = new byte[0];

            ISession     s = OpenSession();
            ITransaction t = s.BeginTransaction();

            s.Save(bcBinary);
            t.Commit();
            s.Close();

            s = OpenSession();
            t = s.BeginTransaction();
            BinaryClass bcBinaryLoaded = (BinaryClass)s.Load(typeof(BinaryClass), 1);

            Assert.IsNotNull(bcBinaryLoaded);
            Assert.AreEqual(0, bcBinaryLoaded.DefaultSize.Length,
                            "A property mapped as type=\"Byte[]\" with a byte[0] value was not saved & loaded as byte[0]");
            Assert.AreEqual(0, bcBinaryLoaded.WithSize.Length,
                            "A property mapped as type=\"Byte[](length)\" with a byte[0] value was not saved & loaded as byte[0]");

            s.Delete(bcBinaryLoaded);
            t.Commit();
            s.Close();
        }
Exemple #2
0
        public void ReadWrite()
        {
            BinaryClass bcBinary = Create(1);
            BinaryClass expected = Create(1);

            ISession     s = OpenSession();
            ITransaction t = s.BeginTransaction();

            s.Save(bcBinary);
            t.Commit();
            s.Close();

            s        = OpenSession();
            t        = s.BeginTransaction();
            bcBinary = (BinaryClass)s.Load(typeof(BinaryClass), 1);

            // make sure what was saved was expected
            ObjectAssert.AreEqual(expected.DefaultSize, bcBinary.DefaultSize);
            ObjectAssert.AreEqual(expected.WithSize, bcBinary.WithSize);

            Assert.IsFalse(s.IsDirty(), "The session is dirty: an Update will be raised on commit, See NH-1246");

            s.Delete(bcBinary);
            t.Commit();
            s.Close();
        }
Exemple #3
0
        public void InsertNull()
        {
            BinaryClass bcBinary = new BinaryClass();

            bcBinary.Id = 1;

            bcBinary.DefaultSize = null;
            bcBinary.WithSize    = null;

            ISession     s = OpenSession();
            ITransaction t = s.BeginTransaction();

            s.Save(bcBinary);
            t.Commit();
            s.Close();

            s = OpenSession();
            t = s.BeginTransaction();
            BinaryClass bcBinaryLoaded = (BinaryClass)s.Load(typeof(BinaryClass), 1);

            Assert.IsNotNull(bcBinaryLoaded);
            Assert.AreEqual(null, bcBinaryLoaded.DefaultSize,
                            "A property mapped as type=\"Byte[]\" with a null byte[] value was not saved & loaded as null");
            Assert.AreEqual(null, bcBinaryLoaded.WithSize,
                            "A property mapped as type=\"Byte[](length)\" with null byte[] value was not saved & loaded as null");

            s.Delete(bcBinaryLoaded);
            t.Commit();
            s.Close();
        }
		public void InsertZeroLength() 
		{
			if (typeof(Dialect.Oracle9Dialect).IsInstanceOfType( dialect)) {
				return;
			}
			BinaryClass bcBinary = new BinaryClass();
			bcBinary.Id = 1;

			bcBinary.DefaultSize = new byte[0];
			bcBinary.WithSize = new byte[0];

			ISession s = OpenSession();
			s.Save(bcBinary);
			s.Flush();
			s.Close();

			s = OpenSession();
			BinaryClass bcBinaryLoaded = (BinaryClass)s.Load( typeof(BinaryClass), 1 );

			Assert.IsNotNull(bcBinaryLoaded);
			Assert.AreEqual(0, bcBinaryLoaded.DefaultSize.Length, "A property mapped as type=\"Byte[]\" with a byte[0] value was not saved & loaded as byte[0]");
			Assert.AreEqual(0, bcBinaryLoaded.WithSize.Length, "A property mapped as type=\"Byte[](length)\" with a byte[0] value was not saved & loaded as byte[0]");

			s.Delete(bcBinaryLoaded);
			s.Flush();
			s.Close();
		}
		public void InsertZeroLength()
		{
			if (Dialect is Oracle8iDialect)
			{
				Assert.Ignore("Certain drivers (ie - Oralce) don't handle writing and reading byte[0]");
			}
			BinaryClass bcBinary = new BinaryClass();
			bcBinary.Id = 1;

			bcBinary.DefaultSize = new byte[0];
			bcBinary.WithSize = new byte[0];

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			s.Save(bcBinary);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			BinaryClass bcBinaryLoaded = (BinaryClass) s.Load(typeof(BinaryClass), 1);

			Assert.IsNotNull(bcBinaryLoaded);
			Assert.AreEqual(0, bcBinaryLoaded.DefaultSize.Length,
			                "A property mapped as type=\"Byte[]\" with a byte[0] value was not saved & loaded as byte[0]");
			Assert.AreEqual(0, bcBinaryLoaded.WithSize.Length,
			                "A property mapped as type=\"Byte[](length)\" with a byte[0] value was not saved & loaded as byte[0]");

			s.Delete(bcBinaryLoaded);
			t.Commit();
			s.Close();
		}
		public void InsertNull()
		{
			BinaryClass bcBinary = new BinaryClass();
			bcBinary.Id = 1;

			bcBinary.DefaultSize = null;
			bcBinary.WithSize = null;

			ISession s = OpenSession();
			ITransaction t = s.BeginTransaction();
			s.Save(bcBinary);
			t.Commit();
			s.Close();

			s = OpenSession();
			t = s.BeginTransaction();
			BinaryClass bcBinaryLoaded = (BinaryClass) s.Load(typeof(BinaryClass), 1);

			Assert.IsNotNull(bcBinaryLoaded);
			Assert.AreEqual(null, bcBinaryLoaded.DefaultSize,
			                "A property mapped as type=\"Byte[]\" with a null byte[] value was not saved & loaded as null");
			Assert.AreEqual(null, bcBinaryLoaded.WithSize,
			                "A property mapped as type=\"Byte[](length)\" with null byte[] value was not saved & loaded as null");

			s.Delete(bcBinaryLoaded);
			t.Commit();
			s.Close();
		}
Exemple #7
0
        private BinaryClass Create(int id)
        {
            BinaryClass bcBinary = new BinaryClass();

            bcBinary.Id = id;

            bcBinary.DefaultSize = GetByteArray(5);
            bcBinary.WithSize    = GetByteArray(10);

            return(bcBinary);
        }
		private BinaryClass Create(int id) 
		{
			BinaryClass bcBinary = new BinaryClass();
			bcBinary.Id = id;

			bcBinary.DefaultSize = GetByteArray(5);
			bcBinary.WithSize = GetByteArray(10);

			return bcBinary;
		}