public void should_delete_user_and_addresses()
        {
            var userRepo = new UserDataRepository();
            var user = new UserData { Email = "*****@*****.**", FirstName = "Unit", LastName = "test", Notes = "Unit test user" };
            userRepo.Add(user);

            UserData returnUser;

            using (ISession session = NBHelper.OpenSession())
                returnUser = session.Get<UserData>(user.Id);

            var addrRepo = new AddressDataRepository();
            var addr = new AddressData { City = "Testville", State = "NJ", Street1 = "Test1", Street2 = "Test2", UserId = returnUser.Id };
            addrRepo.Add(addr);

            AddressData returnAddress;

            using (ISession session = NBHelper.OpenSession())
                returnAddress = session.Get<AddressData>(addr.Id);

            // delete the User
            userRepo.Delete(returnUser);
            using (ISession session = NBHelper.OpenSession())
            {
                var result = session.Get<UserData>(returnUser.Id);
                Assert.IsNull(result);
            }
        }
        public void can_create_new_user_with_address()
        {
            var userRepo = new UserDataRepository();
            var user = new UserData { Email = "*****@*****.**", FirstName = "Unit", LastName = "test", Notes = "Unit test user" };
            userRepo.Add(user);

            UserData returnUser;

            using (ISession session = NBHelper.OpenSession())
            {
                returnUser = session.Get<UserData>(user.Id);
                Assert.IsNotNull(returnUser);
                Assert.IsNotNull(returnUser.Id);
            }

            var addrRepo = new AddressDataRepository();
            // with the User, create an address.
            var addr = new AddressData {City = "Testville", State="NJ", Street1 = "Test1", Street2 = "Test2", UserId = returnUser.Id};
            addrRepo.Add(addr);

            using (ISession session = NBHelper.OpenSession())
            {
                var result = session.Get<AddressData>(addr.Id);
                Assert.IsNotNull(result);
                Assert.IsNotNull(result.Id);
                Assert.AreEqual(returnUser.Id, result.UserId);
            }
        }
        public void can_create_new_record()
        {
            var repo = new AddressDataRepository();
            AddressData addr = new AddressData{Street1 = "XXX N Test Steet", Street2 = "", City = "Philadelphia", State = "PA", Zip = "19147", Type = "TEST"};
            repo.Add(addr);

            using (ISession session = NBHelper.OpenSession())
            {
                var result = session.Get<AddressData>(addr.Id);
                Assert.IsNotNull(result);
                Assert.AreNotSame(addr, result);
                Assert.AreEqual(addr.Street1, result.Street1);
            }
        }
 // this is used to translate data objects to business obects.
 // Allows the BLL to only care about the data it needs to use thus not all data needs to flow from DAL to the BLL
 // and possibly to the UI to worry about.
 public static Address SetEntity(AddressData addrData)
 {
     return new Address
                {
                    Tags = Tag.SetEntity(addrData.Tags),
                    City = addrData.City,
                    Favorite = addrData.Favorite,
                    Id = addrData.Id,
                    Street1 = addrData.Street1,
                    Street2 = addrData.Street2,
                    State = addrData.State,
                    Type = addrData.Type,
                    UserId = addrData.UserId,
                    Zip = addrData.Zip
                };
 }