public void CanAddNewMember()
        {
            var member = new Member {Email = "*****@*****.**", FullName = "Magnus", Password = "******", UserName = "******"};

            IMemberRepository repository = new MemberRepository();
            repository.Add(member);

            // use session to try to load the product
            using (ISession session = _sessionFactory.OpenSession())
            {
                var fromDb = session.Get<Member>(member.Id);
                // Test that the product was successfully inserted

                Assert.IsNotNull(fromDb);
                Assert.AreNotSame(member, fromDb);
                Assert.AreEqual(member.FullName, fromDb.FullName);
                Assert.AreEqual(member.Email, fromDb.Email);
                Assert.AreEqual(member.Password, fromDb.Password);
            }
        }
Esempio n. 2
0
        public bool CreateUser(string username, string email, string password, string fullname)
        {
            IMemberRepository mr = new MemberRepository();

            string passwordHash = FormsAuthentication.HashPasswordForStoringInConfigFile(
                                      password+username, "sha1");

            var member = new Member {UserName = username, Email = email, Password = passwordHash, FullName = fullname};

            try
            {
                mr.Add(member);
            }
            catch
            {
                return false;
            }

            return true;
        }
        public void CannotAddIdenticalEmails()
        {
            var member = new Member { Email = "[email protected]", FullName = "Kalle Ada", Password = "******" };

            IMemberRepository repository = new MemberRepository();
            try
            {
                repository.Add(member);
            }
            catch (GenericADOException)
            {
                return;
            }

            Assert.Fail("Should not be able to add two emails of same sort");
        }