Пример #1
0
        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 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);
        }