Exemplo n.º 1
0
        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());
                }
            }
        }
Exemplo 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();
				}
			}
		}
Exemplo n.º 3
0
        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());
                }
            }
        }
Exemplo n.º 4
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();
                }
            }
        }
Exemplo 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();
				}
			}
		}
Exemplo n.º 6
0
        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());
                }
            }
        }
Exemplo n.º 7
0
        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();
            }
        }
Exemplo n.º 8
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();
            }
        }
Exemplo 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();
				}
			}
		}
Exemplo 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();
			}
		}