コード例 #1
0
 public void CanChangeMembersOpenIDSoLongAsNewIDIsNotInUse()
 {
     using (var session = Database.SessionFactory.OpenSession())
     {
         var member = new Member() { OpenId = "www.paulstovell.com/4", FullName = "Paul Stovell", EmailAddress = "*****@*****.**", LastLogin = DateTime.Now };
         var repository = new MembershipRepository(session);
         repository.SaveMember(member);
         var member2 = repository.FindMemberByOpenId("www.paulstovell.com/4");
         member2.FullName = "Fred Stovell";
         member2.OpenId = "www.paulstovell.com/4_1";
         repository.SaveMember(member2);
         var member3 = repository.FindMemberByOpenId("www.paulstovell.com/4_1");
         Assert.AreEqual("Fred Stovell", member3.FullName);
         Assert.AreEqual(null, repository.FindMemberByOpenId("www.paulstovell.com/4"));
     }
 }
コード例 #2
0
 public void CannotChangeMemberOpenIDIfNewIDAlreadyInUse()
 {
     using (var session = Database.SessionFactory.OpenSession())
     {
         var member1 = new Member() { OpenId = "www.paulstovell.com/5", FullName = "Paul Stovell", EmailAddress = "*****@*****.**", LastLogin = DateTime.Now };
         var member2 = new Member() { OpenId = "www.paulstovell.com/6", FullName = "Paul Stovell", EmailAddress = "*****@*****.**", LastLogin = DateTime.Now };
         var repository = new MembershipRepository(session);
         repository.SaveMember(member1);
         repository.SaveMember(member2);
         var member1_1 = repository.FindMemberByOpenId("www.paulstovell.com/6");
         member1_1.OpenId = "www.paulstovell.com/5";
         var result = repository.SaveMember(member1_1);
         Assert.AreEqual(false, result.Valid);
     }
 }