コード例 #1
0
ファイル: Fixture.cs プロジェクト: briandonahue/nhibernate
		public void WhenStaleObjectStateThenMessageContainsEntity()
		{
			using (var scenario = new ParentWithTwoChildrenScenario(Sfi))
			{
				using (var client1 = OpenSession())
				using (var tx1 = client1.BeginTransaction())
				{
					var parentFromClient1 = client1.Get<Parent>(scenario.ParentId);
					NHibernateUtil.Initialize(parentFromClient1.Children);
					var firstChildId = parentFromClient1.Children[0].Id;
					
					DeleteChildUsingAnotherSession(firstChildId);

					parentFromClient1.Children[0].Description = "Modified info";
					var expectedException = tx1.Executing(x => x.Commit()).Throws<StaleObjectStateException>().Exception;
					expectedException.EntityName.Should().Be(typeof(Child).FullName);
					expectedException.Identifier.Should().Be(firstChildId);
				}
			}
		}
コード例 #2
0
ファイル: Fixture.cs プロジェクト: jrauber/GH1429
        public async Task WhenStaleObjectStateThenMessageContainsEntityAsync()
        {
            using (var scenario = new ParentWithTwoChildrenScenario(Sfi))
            {
                using (var client1 = OpenSession())
                {
                    var parentFromClient1 = await(client1.GetAsync <Parent>(scenario.ParentId));
                    await(NHibernateUtil.InitializeAsync(parentFromClient1.Children));
                    var firstChildId = parentFromClient1.Children[0].Id;

                    await(DeleteChildUsingAnotherSessionAsync(firstChildId));

                    using (var tx1 = client1.BeginTransaction())
                    {
                        parentFromClient1.Children[0].Description = "Modified info";
                        var expectedException = Assert.ThrowsAsync <StaleObjectStateException>(() => tx1.CommitAsync());
                        Assert.That(expectedException.EntityName, Is.EqualTo(typeof(Child).FullName));
                        Assert.That(expectedException.Identifier, Is.EqualTo(firstChildId));
                    }
                }
            }
        }
コード例 #3
0
ファイル: Fixture.cs プロジェクト: zmp2000/nhibernate-core
        public void WhenStaleObjectStateThenMessageContainsEntity()
        {
            using (var scenario = new ParentWithTwoChildrenScenario(Sfi))
            {
                using (var client1 = OpenSession())
                {
                    var parentFromClient1 = client1.Get <Parent>(scenario.ParentId);
                    NHibernateUtil.Initialize(parentFromClient1.Children);
                    var firstChildId = parentFromClient1.Children[0].Id;

                    DeleteChildUsingAnotherSession(firstChildId);

                    using (var tx1 = client1.BeginTransaction())
                    {
                        parentFromClient1.Children[0].Description = "Modified info";
                        var expectedException = tx1.Executing(x => x.Commit()).Throws <StaleObjectStateException>().Exception;
                        expectedException.EntityName.Should().Be(typeof(Child).FullName);
                        expectedException.Identifier.Should().Be(firstChildId);
                    }
                }
            }
        }
コード例 #4
0
ファイル: Fixture.cs プロジェクト: marchlud/nhibernate-core
		public void WhenStaleObjectStateThenMessageContainsEntity()
		{
			using (var scenario = new ParentWithTwoChildrenScenario(Sfi))
			{
				using (var client1 = OpenSession())
				{
					var parentFromClient1 = client1.Get<Parent>(scenario.ParentId);
					NHibernateUtil.Initialize(parentFromClient1.Children);
					var firstChildId = parentFromClient1.Children[0].Id;

					DeleteChildUsingAnotherSession(firstChildId);

					using (var tx1 = client1.BeginTransaction())
					{
						parentFromClient1.Children[0].Description = "Modified info";
						var expectedException = Assert.Throws<StaleObjectStateException>(() => tx1.Commit());
						Assert.That(expectedException.EntityName, Is.EqualTo(typeof (Child).FullName));
						Assert.That(expectedException.Identifier, Is.EqualTo(firstChildId));
					}
				}
			}
		}