public void LineageIsBuiltProperly() { var sut = new Member(); sut.SetLineage("z", new List<string> {"a", "b", "c"}); Assert.AreEqual("z", sut.VouchedBy); Assert.AreEqual(4, sut.Lineage.Count); }
public ActionResult Index(InvitationAcceptanceCommand command) { try { var invitation = _session .Include<Invitation>(x => x.VouchedBy) .Load<Invitation>(Invitation.FormatId(command.Token)); invitation.Accept(); var voucher = _session.Load<Member>(invitation.VouchedBy); voucher.RemoveInvite(invitation.Id); var member = new Member { Email = invitation.Email, FullName = invitation.FullName, UserName = command.UserName, LinkedIn = invitation.LinkedIn, GitHub = invitation.GitHub, }; member.SetLineage(voucher.Id, voucher.Lineage); member.SetPassword(command.Password); _session.Store(member); var email = Identifier.FromEmail(invitation.Email, member.Id); member.AddIdentifier(email.Id); _session.Store(email); var username = Identifier.FromUserName(command.UserName, member.Id); member.AddIdentifier(username.Id); _session.Store(username); _session.Advanced.UseOptimisticConcurrency = true; _session.SaveChanges(); _authentication.Login(member.Id); _email.SendAcceptanceNotificationToGroup(member); return RedirectToAction("Index", "Welcome"); } catch (ConcurrencyException) { command.UserNameIsAvailable = false; } catch (ApplicationException e) { ModelState.AddModelError("", e.Message); } return View(command); }