Exemplo n.º 1
0
			protected override void Context()
			{
				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<A>()).Return(new A[0]);

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				result = session.GetOne<A>().Where(a => a.ABC).IsEqualTo("abc").Execute();
			}
Exemplo n.º 2
0
			protected override void Context()
			{
				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<A>()).Return(new[] { new A() });

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				session.GetOne<A>()
					.Where(a => a.DEF).IsLessThan(3)
					.And(a => a.DEF).IsGreaterThan(0)
					.And(a => a.ABC).IsNull()
					.Execute();
			}
			protected override void Context()
			{
				childCriteria = MockRepository.GenerateMock<ICriteria>();

				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<A>()).Return(new[] { new A() });
				criteria.Expect(c => c.CreateCriteria("B")).Return(childCriteria);

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				session.GetOne<A>()
					.ThatHasChild(a => a.B)
					.Where(b => b.GHI).IsEqualTo(true)
					.And(b => b.JKL).IsIn("yo momma")
					.EndChild()
					.Execute();
			}
			protected override void Context()
			{
				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<A>()).Return(new[] { new A() });

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				result = session.GetAll<A>().ThatHasChild(a => a.B).EndChild().Execute();
			}
            protected override void Context()
            {
                criteria = MockRepository.GenerateMock<ICriteria>();
                criteria.Expect(c => c.SetFirstResult(0)).IgnoreArguments().Return(criteria);
                criteria.Expect(c => c.SetMaxResults(0)).IgnoreArguments().Return(criteria);
                criteria.Expect(c => c.List<A>()).Return(new[] { new A(), new A() });

                ISession session = MockRepository.GenerateMock<ISession>();
                session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

                results = session.GetAll<A>().MaxResults(2).Execute();
            }
			protected override void Context()
			{
				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetProjection(null)).IgnoreArguments().Return(criteria);
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<int>()).Return(new[] {8});

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				result = session.GetCount<A>().Execute();
			}
			protected override void Context()
			{
				secondChildCriteria = MockRepository.GenerateMock<ICriteria>();

				childCriteria = MockRepository.GenerateMock<ICriteria>();
				childCriteria.Expect(c => c.CreateCriteria("CList")).Return(secondChildCriteria);

				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<A>()).Return(new[] { new A() });
				criteria.Expect(c => c.CreateCriteria("B")).Return(childCriteria);

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				session.GetOne<A>()
					.ThatHasChild(a => a.B)
					.Where(b => b.GHI).IsNotNull()
					.AndHasChildCollection(b => b.CList)
					.Where(c => c.MNO).IsNotEqualTo(Math.PI)
					.And(c => c.PQR).IsLessThan(DateTime.Today.Subtract(new TimeSpan(5, 0, 0, 0)))
					.EndChild()
					.And(b => b.JKL).IsNotEqualTo('Q')
					.EndChild()
					.Execute();
			}
			protected override void Context()
			{
				secondChildCriteria = MockRepository.GenerateMock<ICriteria>();

				childCriteria = MockRepository.GenerateMock<ICriteria>();
				childCriteria.Expect(c => c.CreateCriteria("CList")).Return(secondChildCriteria);

				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<A>()).Return(new[] { new A() });
				criteria.Expect(c => c.CreateCriteria("B")).Return(childCriteria);

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				session.GetOne<A>()
					.ThatHasChild(a => a.B)
					.ThatHasChildCollection(b => b.CList)
					.Where(c => c.MNO).IsNotEqualTo(Math.PI)
					.EndChild()
					.EndChild()
					.Execute();
			}
			protected override void Context()
			{
				secondChildCriteria = MockRepository.GenerateMock<ICriteria>();

				childCriteria = MockRepository.GenerateMock<ICriteria>();
				childCriteria.Expect(c => c.CreateCriteria("C")).Return(secondChildCriteria);

				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<A>()).Return(new[] { new A() });
				criteria.Expect(c => c.CreateCriteria("B")).Return(childCriteria);

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				session.GetOne<A>()
					.ThatHasChild(a => a.B)
					.Where(b => b.GHI).IsEqualTo(false)
					.AndHasChild(b => b.C)
					.Where(c => c.MNO).IsGreaterThanOrEqualTo(.55)
					.And(c => c.PQR).IsIn(new DateTime?[] { DateTime.Now, DateTime.Today })
					.EndChild()
					.And(b => b.JKL).IsGreaterThanOrEqualTo('X')
					.EndChild()
					.Execute();
			}
			protected override void Context()
			{
				childCriteria = MockRepository.GenerateMock<ICriteria>();

				criteria = MockRepository.GenerateMock<ICriteria>();
				criteria.Expect(c => c.SetMaxResults(1)).Return(criteria);
				criteria.Expect(c => c.List<A>()).Return(new[] { new A() });
				criteria.Expect(c => c.CreateCriteria("BList")).Return(childCriteria);

				ISession session = MockRepository.GenerateMock<ISession>();
				session.Expect(s => s.CreateCriteria(typeof(A))).Return(criteria);

				session.GetOne<A>()
					.Where(a => a.ABC).IsEqualTo("abc")
					.AndHasChildCollection(a => a.BList)
					.Where(b => b.JKL).IsEqualTo('2')
					.EndChild()
					.And(a => a.DEF).IsNotNull()
					.Execute();
			}