Exemplo n.º 1
0
        public void ReadOnlyOnTextType()
        {
            if (!TextHolder.SupportedForDialect(Dialect))
            {
                Assert.Ignore("Dialect doesn't support the 'text' data type.");
            }

            string origText = "some huge text string";
            string newText  = "some even bigger text string";

            ClearCounts();
            long id;

            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    TextHolder holder = new TextHolder(origText);
                    s.Save(holder);
                    id = holder.Id;
                    t.Commit();
                    s.Close();
                }

            AssertInsertCount(1);
            AssertUpdateCount(0);
            ClearCounts();

            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    var holder = s.Get <TextHolder>(id);
                    s.SetReadOnly(holder, true);
                    holder.TheText = newText;
                    s.Flush();
                    t.Commit();
                    s.Close();
                }

            AssertUpdateCount(0);

            using (var s = OpenSession())
                using (var t = s.BeginTransaction())
                {
                    var holder = s.Get <TextHolder>(id);
                    Assert.That(origText, Is.EqualTo(holder.TheText), "change written to database");
                    s.Delete(holder);
                    t.Commit();
                    s.Close();
                }

            AssertUpdateCount(0);
            AssertDeleteCount(1);
        }
Exemplo n.º 2
0
        public async Task ReadOnlyOnTextTypeAsync()
        {
            if (!TextHolder.SupportedForDialect(Dialect))
            {
                Assert.Ignore("Dialect doesn't support the 'text' data type.");
            }

            string origText = "some huge text string";
            string newText  = "some even bigger text string";

            ClearCounts();

            ISession s = OpenSession();

            s.BeginTransaction();
            TextHolder holder = new TextHolder(origText);

            await(s.SaveAsync(holder));
            long id = holder.Id;

            await(s.Transaction.CommitAsync());
            s.Close();

            AssertInsertCount(1);
            AssertUpdateCount(0);
            ClearCounts();

            s = OpenSession();
            s.BeginTransaction();
            holder = await(s.GetAsync <TextHolder>(id));
            s.SetReadOnly(holder, true);
            holder.TheText = newText;
            await(s.FlushAsync());
            await(s.Transaction.CommitAsync());
            s.Close();

            AssertUpdateCount(0);

            s = OpenSession();
            s.BeginTransaction();
            holder = await(s.GetAsync <TextHolder>(id));
            Assert.That(origText, Is.EqualTo(holder.TheText), "change written to database");
            await(s.DeleteAsync(holder));
            await(s.Transaction.CommitAsync());
            s.Close();

            AssertUpdateCount(0);
            AssertDeleteCount(1);
        }
Exemplo n.º 3
0
        public void ReadOnlyOnTextType()
        {
            if (!TextHolder.SupportedForDialect(Dialect))
            {
                Assert.Ignore("Dialect doesn't support the 'text' data type.");
            }

            string origText = "some huge text string";
            string newText  = "some even bigger text string";
            long   id       = 0;

            using (ISession s = OpenSession())
            {
                s.CacheMode = CacheMode.Ignore;
                using (ITransaction t = s.BeginTransaction())
                {
                    TextHolder holder = new TextHolder(origText);
                    s.Save(holder);
                    id = holder.Id;
                    t.Commit();
                }
            }

            using (ISession s = OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    s.DefaultReadOnly = true;
                    s.CacheMode       = CacheMode.Ignore;
                    TextHolder holder = s.Get <TextHolder>(id);
                    s.DefaultReadOnly = false;
                    holder.TheText    = newText;
                    s.Flush();
                    t.Commit();
                }
            }

            using (ISession s = OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    TextHolder holder = s.Get <TextHolder>(id);
                    Assert.That(holder.TheText, Is.EqualTo(origText), "change written to database");
                    s.Delete(holder);
                    t.Commit();
                }
            }
        }
Exemplo n.º 4
0
        public void ReadOnlyOnTextType()
        {
            string origText = "some huge text string";
            string newText  = "some even bigger text string";

            ClearCounts();

            ISession s = OpenSession();

            s.BeginTransaction();
            TextHolder holder = new TextHolder(origText);

            s.Save(holder);
            long id = holder.Id;

            s.Transaction.Commit();
            s.Close();

            AssertInsertCount(1);
            AssertUpdateCount(0);
            ClearCounts();

            s = OpenSession();
            s.BeginTransaction();
            holder = s.Get <TextHolder>(id);
            s.SetReadOnly(holder, true);
            holder.TheText = newText;
            s.Flush();
            s.Transaction.Commit();
            s.Close();

            AssertUpdateCount(0);

            s = OpenSession();
            s.BeginTransaction();
            holder = s.Get <TextHolder>(id);
            Assert.That(origText, Is.EqualTo(holder.TheText), "change written to database");
            s.Delete(holder);
            s.Transaction.Commit();
            s.Close();

            AssertUpdateCount(0);
            AssertDeleteCount(1);
        }
		public void ReadOnlyOnTextType()
		{
			if (!TextHolder.SupportedForDialect(Dialect))
				Assert.Ignore("Dialect doesn't support the 'text' data type.");

			string origText = "some huge text string";
			string newText = "some even bigger text string";
			long id = 0;
			
			using (ISession s = OpenSession())
			{
				s.CacheMode = CacheMode.Ignore;
				using (ITransaction t = s.BeginTransaction())
				{
					TextHolder holder = new TextHolder(origText);
					s.Save(holder);
					id = holder.Id;
					t.Commit();
				}
			}
			
			using (ISession s = OpenSession())
			{
				using (ITransaction t = s.BeginTransaction())
				{
					s.DefaultReadOnly = true;
					s.CacheMode = CacheMode.Ignore;
					TextHolder holder = s.Get<TextHolder>(id);
					s.DefaultReadOnly = false;
					holder.TheText = newText;
					s.Flush();
					t.Commit();
				}
			}

			using (ISession s = OpenSession())
			{
				using (ITransaction t = s.BeginTransaction())
				{
					TextHolder holder = s.Get<TextHolder>(id);
					Assert.That(holder.TheText, Is.EqualTo(origText), "change written to database");
					s.Delete(holder);
					t.Commit();
				}
			}
		}
Exemplo n.º 6
0
		public void ReadOnlyOnTextType()
		{
			if (!TextHolder.SupportedForDialect(Dialect))
				Assert.Ignore("Dialect doesn't support the 'text' data type.");

			string origText = "some huge text string";
			string newText = "some even bigger text string";
	
			ClearCounts();
	
			ISession s = OpenSession();
			s.BeginTransaction();
			TextHolder holder = new TextHolder(origText);
			s.Save(holder);
			long id = holder.Id;
			s.Transaction.Commit();
			s.Close();
	
			AssertInsertCount(1);
			AssertUpdateCount(0);
			ClearCounts();
	
			s = OpenSession();
			s.BeginTransaction();
			holder = s.Get<TextHolder>(id);
			s.SetReadOnly(holder, true);
			holder.TheText = newText;
			s.Flush();
			s.Transaction.Commit();
			s.Close();
	
			AssertUpdateCount(0);
	
			s = OpenSession();
			s.BeginTransaction();
			holder = s.Get<TextHolder>(id);
			Assert.That(origText, Is.EqualTo(holder.TheText), "change written to database");
			s.Delete(holder);
			s.Transaction.Commit();
			s.Close();
	
			AssertUpdateCount(0);
			AssertDeleteCount(1);
		}