public void LazyLoadWillFailOnceObjectDetatched() { //given Guid id = DbFixture.Insert(Om.CreateCustomerWithOneRep()); //when var detatchedInstance = Nh.CurrentSession.Get <Customer>(id); Nh.CurrentSession.Evict(detatchedInstance); //then Assert.Throws <LazyInitializationException>(() => detatchedInstance.CustomerRepresentatives.At(0)); }
public void CanTestWhenAssociationIsLazyLoaded() { //given Customer customer = Om.CreateCustomerWithOneRep(); DbFixture.Insert(customer); //when var loadedCustomer = Nh.GetFromDb <Customer>(customer.Id); //then NhAssert.IsLazyLoaded(loadedCustomer.CustomerRepresentatives); }