示例#1
0
        public void MustFirstSaveReferencedObjectBeforeSavingRefereningObject()
        {
            //given
            Customer customer = Om.CreateCustomer();
            Order    order    = Om.CreateOrderWith(customer);

            //this would not happen if persistence cascaded from Order to Customer
            NhAssert.VerifyInsertThrowsBecausePropertyReferencesUnsavedInstance(order, x => x.Customer);
        }
示例#2
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);
        }