public Membership Update(Membership item) { Repo.Update(item); Unit.SaveChanges(); return item; }
public void Put(Membership membership) { memberships[membership.Id] = membership; }
public void MembershipRepository() { Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>(); Mock<DbSet<Membership>> dbSet = new Mock<DbSet<Membership>>(); factory.Setup(m => m.CreateDbSet<Membership>()).Returns(dbSet.Object); MembershipRepository repo = new MembershipRepository(factory.Object); var Membership = new Membership(); var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(Membership)); dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id)); repo.Create(Membership); repo.Get(Membership.Id); repo.Update(Membership); repo.Delete(Membership.Id); }
public void MembershipLogic() { Mock<IUnitOfWork> uow = new Mock<IUnitOfWork>(); Mock<IMembershipRepository> repo = new Mock<IMembershipRepository>(); MembershipLogic logic = new MembershipLogic(uow.Object, repo.Object); var membership = new Membership(); var sequence = new MockSequence(); repo.InSequence(sequence).Setup(r => r.Create(membership)); repo.InSequence(sequence).Setup(r => r.Update(membership)); repo.InSequence(sequence).Setup(r => r.Get(membership.Id)); repo.InSequence(sequence).Setup(r => r.Delete(membership.Id)); logic.Create(membership); logic.Update(membership); logic.Get(membership.Id); logic.Delete(membership.Id); }