Ejemplo n.º 1
0
        protected override void Act()
        {
            var hero = data.PickOne <SuperHero>();
            var id   = hero.Id;

            spy = new NHibernateSqlLogSpy();
            data.NHibernateSession.Clear();
            var handler = new GetSuperHeroHandler(new GetSuperHeroQuery(data.NHibernateSession));

            handler.Handle(id);
        }
Ejemplo n.º 2
0
        public void DoesNotCauseLazyLoading()
        {
            var superhero =
                new DomainGenerator()
                .With <IHaveAnId>(opt => opt.Ignore(e => e.Id))
                .OneToMany <SuperHero, SuperPower>(5, (sh, sp) => sh.SuperPowers.Add(sp))
                .ForEach <IHaveAnId>(SaveToSession)
                .One <SuperHero>();

            FlushAndClear();

            var id = superhero.Id;

            var handler = new GetSuperHeroHandler(new GetSuperHeroQuery(NHibernateSession));

            using (1.Queries())
            {
                handler.Handle(id);
            }
        }
        public void DoesNotCauseLazyLoading()
        {
            var generator =
                from _ in MGen.For <IHaveAnId>().Ignore(e => e.Id)
                from powers in MGen.One <SuperPower>().Many(5)
                from hero in MGen.One <SuperHero>()
                .Apply(e => SaveToSession(e))
                .Apply(h => powers.ForEach(p => h.SuperPowers.Add(p)))
                select hero;

            var superhero = generator.Generate();

            FlushAndClear();

            var id = superhero.Id;

            var handler = new GetSuperHeroHandler(new GetSuperHeroQuery(NHibernateSession));

            using (1.Queries())
            {
                handler.Handle(id);
            }
        }