コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: MoodController.cs プロジェクト: heidijane/Journly
 public MoodController(ApplicationDbContext context, IConfiguration configuration)
 {
     _moodRepository = new MoodRepository(context);
     _userRepository = new UserRepository(context, configuration);
 }