public void MoodRepository() { Mock <IDbSetFactory> factory = new Mock <IDbSetFactory>(); Mock <DbSet <Mood> > dbSet = new Mock <DbSet <Mood> >(); factory.Setup(m => m.CreateDbSet <Mood>()).Returns(dbSet.Object); MoodRepository repo = new MoodRepository(factory.Object); var Mood = new Mood(); var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(Mood)); dbSet.InSequence(sequence).Setup(e => e.Find(Mood.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Mood.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Mood.Id)); repo.Create(Mood); repo.Get(Mood.Id); repo.Update(Mood); repo.Delete(Mood.Id); }
public void MoodRepository() { Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>(); Mock<DbSet<Mood>> dbSet = new Mock<DbSet<Mood>>(); factory.Setup(m => m.CreateDbSet<Mood>()).Returns(dbSet.Object); MoodRepository repo = new MoodRepository(factory.Object); var Mood = new Mood(); var sequence = new MockSequence(); dbSet.InSequence(sequence).Setup(e => e.Add(Mood)); dbSet.InSequence(sequence).Setup(e => e.Find(Mood.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Mood.Id)); dbSet.InSequence(sequence).Setup(e => e.Find(Mood.Id)); repo.Create(Mood); repo.Get(Mood.Id); repo.Update(Mood); repo.Delete(Mood.Id); }
public MoodController(ApplicationDbContext context, IConfiguration configuration) { _moodRepository = new MoodRepository(context); _userRepository = new UserRepository(context, configuration); }