Ejemplo n.º 1
0
 public void ShouldAddAContactWithAddress_usingEF2()
 {
     var mfPaymentModel = new MFPaymentModel();
     var contact = new Domain.Contact{Name = "Test"};
     //var address = new Domain.Address{Contact = contact, Street = "Lipowa 5"};
     //contact.Address = address;
     //TODO: Relationship
     mfPaymentModel.Contacts.AddObject(contact);
 }
Ejemplo n.º 2
0
        public void ContactHasOneOrZeroAddresses_AddressHasOneContact_WithNHibernate()
        {
            using (new TransactionScope())
            {
                ISession session = ServiceLocator.Factory.OpenSession();
                var address = new Domain.Address{Street = "Lipowa"};
                var contact = new Domain.Contact {Name = "Test", Address = address};
                address.Contact = contact;

                using(ITransaction transaction = session.BeginTransaction())
                {
                    session.Save(contact);
                    transaction.Commit();
                }
                session = ServiceLocator.Factory.OpenSession();
                using (ITransaction transaction = session.BeginTransaction())
                {
                    IList<Domain.Contact> contacts = session.Linq<Domain.Contact>().Where(x => x.Name == "Test").ToList();
                    Assert.That(contacts.Count, Is.EqualTo(1));
                }
            }
        }