예제 #1
0
        public async void Create()
        {
            Mock <ILogger <CommentsRepository> > loggerMoc = CommentsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CommentsRepositoryMoc.GetContext();
            var repository = new CommentsRepository(loggerMoc.Object, context);

            var entity = new Comments();
            await repository.Create(entity);

            var record = await context.Set <Comments>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
예제 #2
0
        public async void Get()
        {
            Mock <ILogger <CommentsRepository> > loggerMoc = CommentsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CommentsRepositoryMoc.GetContext();
            var repository = new CommentsRepository(loggerMoc.Object, context);

            Comments entity = new Comments();

            context.Set <Comments>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
예제 #3
0
        public async void Delete()
        {
            Mock <ILogger <CommentsRepository> > loggerMoc = CommentsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CommentsRepositoryMoc.GetContext();
            var      repository          = new CommentsRepository(loggerMoc.Object, context);
            Comments entity = new Comments();

            context.Set <Comments>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            Comments modifiedRecord = await context.Set <Comments>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
예제 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <CommentsRepository> > loggerMoc = CommentsRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = CommentsRepositoryMoc.GetContext();
            var      repository          = new CommentsRepository(loggerMoc.Object, context);
            Comments entity = new Comments();

            context.Set <Comments>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new Comments());

            var modifiedRecord = context.Set <Comments>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }