예제 #1
0
파일: Fixture.cs 프로젝트: jrauber/GH1429
        public void ComplexNest()
        {
            Component comp1 = GetInitializedComponent();
            var       nest  = new Nest {
                Name = "NAME", Components = new List <Component> {
                    comp1
                }
            };
            var deep1 = new DeepComponent {
                Prop1 = "PROP1", Prop2 = "PROP2", Prop3 = "PROP3", Prop4 = "PROP4"
            };
            Component innerComp = GetInitializedComponent();

            deep1.Component = innerComp;
            Component innerComp2 = GetInitializedComponent();
            var       deep2      = new DeepComponent
            {
                Prop1 = "PROP1", Prop2 = "PROP2", Prop3 = "PROP3", Prop4 = "PROP4", Component = innerComp2
            };

            nest.ComplexComponents = new List <DeepComponent> {
                deep1, deep2
            };

            object nestId;

            using (ISession session = OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(nest);
                    transaction.Commit();
                    nestId = nest.Id;
                }
            }

            using (ISession session = OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var loadedNest = session.Load <Nest>(nestId);
                    transaction.Commit();

                    Assert.AreEqual(2, loadedNest.ComplexComponents.Count);
                    Assert.IsNotNull(((DeepComponent)loadedNest.ComplexComponents[0]).Component.SubComponent.Nested.SubName1);
                    Assert.IsNull(((DeepComponent)loadedNest.ComplexComponents[0]).Component.SubComponent.SubName1);
                }
            }

            using (ISession s = OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    s.Delete("from Nest");
                    t.Commit();
                }
            }
        }
예제 #2
0
		public void ComplexNest()
		{
			Component comp1 = GetInitializedComponent();
			var nest = new Nest {Name = "NAME", Components = new ArrayList {comp1}};
			var deep1 = new DeepComponent {Prop1 = "PROP1", Prop2 = "PROP2", Prop3 = "PROP3", Prop4 = "PROP4"};
			Component innerComp = GetInitializedComponent();
			deep1.Component = innerComp;
			Component innerComp2 = GetInitializedComponent();
			var deep2 = new DeepComponent
			            	{Prop1 = "PROP1", Prop2 = "PROP2", Prop3 = "PROP3", Prop4 = "PROP4", Component = innerComp2};

			nest.ComplexComponents = new ArrayList {deep1, deep2};

			object nestId;
			using (ISession session = OpenSession())
			{
				using (ITransaction transaction = session.BeginTransaction())
				{
					session.Save(nest);
					transaction.Commit();
					nestId = nest.Id;
				}
			}

			using (ISession session = OpenSession())
			{
				using (ITransaction transaction = session.BeginTransaction())
				{
					var loadedNest = session.Load<Nest>(nestId);
					transaction.Commit();

					Assert.AreEqual(2, loadedNest.ComplexComponents.Count);
					Assert.IsNotNull(((DeepComponent) loadedNest.ComplexComponents[0]).Component.SubComponent.Nested.SubName1);
					Assert.IsNull(((DeepComponent) loadedNest.ComplexComponents[0]).Component.SubComponent.SubName1);
				}
			}

			using (ISession s = OpenSession())
			{
				using (ITransaction t = s.BeginTransaction())
				{
					s.Delete("from Nest");
					t.Commit();
				}
			}
		}
예제 #3
0
파일: Fixture.cs 프로젝트: jrauber/GH1429
        public void NestedComponentCollection()
        {
            var nest = new Nest {
                Name = "NAME"
            };
            Component comp1 = GetInitializedComponent();

            nest.Components = new List <Component> {
                comp1
            };

            object nestId;

            using (ISession session = OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(nest);
                    transaction.Commit();
                    nestId = nest.Id;
                }
            }

            using (ISession session = OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var nest2 = session.Load <Nest>(nestId);
                    transaction.Commit();

                    Assert.IsNotNull(((Component)nest2.Components[0]).SubComponent.Nested.SubName);
                }
            }

            using (ISession s = OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    s.Delete("from Nest");
                    t.Commit();
                }
            }
        }
예제 #4
0
        public async Task NestedComponentCollectionAsync()
        {
            var nest = new Nest {
                Name = "NAME"
            };
            Component comp1 = GetInitializedComponent();

            nest.Components = new List <Component> {
                comp1
            };

            object nestId;

            using (ISession session = OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    await(session.SaveAsync(nest));
                    await(transaction.CommitAsync());
                    nestId = nest.Id;
                }
            }

            using (ISession session = OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    var nest2 = await(session.LoadAsync <Nest>(nestId));
                    await(transaction.CommitAsync());

                    Assert.IsNotNull(((Component)nest2.Components[0]).SubComponent.Nested.SubName);
                }
            }

            using (ISession s = OpenSession())
            {
                using (ITransaction t = s.BeginTransaction())
                {
                    await(s.DeleteAsync("from Nest"));
                    await(t.CommitAsync());
                }
            }
        }
예제 #5
0
		public void NestedComponentCollection()
		{
			var nest = new Nest {Name = "NAME"};
			Component comp1 = GetInitializedComponent();

			nest.Components = new ArrayList {comp1};

			object nestId;
			using (ISession session = OpenSession())
			{
				using (ITransaction transaction = session.BeginTransaction())
				{
					session.Save(nest);
					transaction.Commit();
					nestId = nest.Id;
				}
			}

			using (ISession session = OpenSession())
			{
				using (ITransaction transaction = session.BeginTransaction())
				{
					var nest2 = session.Load<Nest>(nestId);
					transaction.Commit();

					Assert.IsNotNull(((Component) nest2.Components[0]).SubComponent.Nested.SubName);
				}
			}

			using (ISession s = OpenSession())
			{
				using (ITransaction t = s.BeginTransaction())
				{
					s.Delete("from Nest");
					t.Commit();
				}
			}
		}