public async Task RefreshCascadeAsync()
        {
            using (ISession session = OpenSession())
            {
                using (ITransaction txn = session.BeginTransaction())
                {
                    JobBatch batch = new JobBatch(DateTime.Now);
                    batch.CreateJob().ProcessingInstructions = "Just do it!";
                    batch.CreateJob().ProcessingInstructions = "I know you can do it!";

                    // write the stuff to the database; at this stage all job.status values are zero
                    await(session.PersistAsync(batch));
                    await(session.FlushAsync());

                    // behind the session's back, let's modify the statuses
                    await(UpdateStatusesAsync(session));

                    // Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements
                    await(session.RefreshAsync(batch));

                    foreach (Job job in batch.Jobs)
                    {
                        Assert.That(job.Status, Is.EqualTo(1), "Jobs not refreshed!");
                    }

                    await(txn.RollbackAsync());
                }
            }
        }
Esempio n. 2
0
		public void RefreshCascade()
		{
			using(ISession session = OpenSession())
			{
				using (ITransaction txn = session.BeginTransaction())
				{
					JobBatch batch = new JobBatch(DateTime.Now);
					batch.CreateJob().ProcessingInstructions = "Just do it!";
					batch.CreateJob().ProcessingInstructions = "I know you can do it!";

					// write the stuff to the database; at this stage all job.status values are zero
					session.Persist(batch);
					session.Flush();

					// behind the session's back, let's modify the statuses
					UpdateStatuses(session);

					// Now lets refresh the persistent batch, and see if the refresh cascaded to the jobs collection elements
					session.Refresh(batch);

					foreach (Job job in batch.Jobs)
					{
						Assert.That(job.Status, Is.EqualTo(1), "Jobs not refreshed!");
					}

					txn.Rollback();
				}
			}
		}
        public async Task RefreshIgnoringTransientAsync()
        {
            // No exception expected
            using (ISession session = OpenSession())
            {
                using (ITransaction txn = session.BeginTransaction())
                {
                    var batch = new JobBatch(DateTime.Now);
                    await(session.RefreshAsync(batch));

                    await(txn.RollbackAsync());
                }
            }
        }
        public void RefreshIgnoringTransient()
        {
            // No exception expected
            using (ISession session = OpenSession())
            {
                using (ITransaction txn = session.BeginTransaction())
                {
                    var batch = new JobBatch(DateTime.Now);
                    session.Refresh(batch);

                    txn.Rollback();
                }
            }
        }
Esempio n. 5
0
		public void RefreshIgnoringTransient()
		{
			// No exception expected
			using (ISession session = OpenSession())
			{
				using (ITransaction txn = session.BeginTransaction())
				{
					var batch = new JobBatch(DateTime.Now);
					session.Refresh(batch);

					txn.Rollback();
				}
			}
		}
        public async Task RefreshIgnoringTransientInCollectionAsync()
        {
            using (ISession session = OpenSession())
            {
                using (ITransaction txn = session.BeginTransaction())
                {
                    var batch = new JobBatch(DateTime.Now);
                    batch.CreateJob().ProcessingInstructions = "Just do it!";
                    await(session.PersistAsync(batch));
                    await(session.FlushAsync());

                    batch.CreateJob().ProcessingInstructions = "I know you can do it!";
                    await(session.RefreshAsync(batch));
                    Assert.That(batch.Jobs.Count == 1);

                    await(txn.RollbackAsync());
                }
            }
        }
        public async Task RefreshNotIgnoringTransientByUnsavedValueAsync()
        {
            ISession     session = OpenSession();
            ITransaction txn     = session.BeginTransaction();

            var batch = new JobBatch {
                BatchDate = DateTime.Now, Id = 1
            };

            try
            {
                await(session.RefreshAsync(batch));
            }
            catch (UnresolvableObjectException)
            {
                // as expected
                await(txn.RollbackAsync());
                session.Close();
            }
        }
        public void RefreshNotIgnoringTransientByUnsavedValue()
        {
            ISession     session = OpenSession();
            ITransaction txn     = session.BeginTransaction();

            var batch = new JobBatch {
                BatchDate = DateTime.Now, Id = 1
            };

            try
            {
                session.Refresh(batch);
            }
            catch (UnresolvableObjectException)
            {
                // as expected
                txn.Rollback();
                session.Close();
            }
        }
Esempio n. 9
0
		public void RefreshIgnoringTransientInCollection()
		{
			using (ISession session = OpenSession())
			{
				using (ITransaction txn = session.BeginTransaction())
				{

					var batch = new JobBatch(DateTime.Now);
					batch.CreateJob().ProcessingInstructions = "Just do it!";
					session.Persist(batch);
					session.Flush();

					batch.CreateJob().ProcessingInstructions = "I know you can do it!";
					session.Refresh(batch);
					Assert.That(batch.Jobs.Count == 1);

					txn.Rollback();
				}
			}
		}
Esempio n. 10
0
		public void RefreshNotIgnoringTransientByUnsavedValue()
		{
			ISession session = OpenSession();
			ITransaction txn = session.BeginTransaction();

			var batch = new JobBatch { BatchDate = DateTime.Now, Id = 1 };
			try
			{
				session.Refresh(batch);
			}
			catch (UnresolvableObjectException)
			{
				// as expected
				txn.Rollback();
				session.Close();
			}
		}