コード例 #1
0
        public async void Create()
        {
            Mock <ILogger <VotesRepository> > loggerMoc = VotesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VotesRepositoryMoc.GetContext();
            var repository = new VotesRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
コード例 #2
0
        public async void Get()
        {
            Mock <ILogger <VotesRepository> > loggerMoc = VotesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VotesRepositoryMoc.GetContext();
            var repository = new VotesRepository(loggerMoc.Object, context);

            Votes entity = new Votes();

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

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

            record.Should().NotBeNull();
        }
コード例 #3
0
        public async void Delete()
        {
            Mock <ILogger <VotesRepository> > loggerMoc = VotesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VotesRepositoryMoc.GetContext();
            var   repository             = new VotesRepository(loggerMoc.Object, context);
            Votes entity = new Votes();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
コード例 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <VotesRepository> > loggerMoc = VotesRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VotesRepositoryMoc.GetContext();
            var   repository             = new VotesRepository(loggerMoc.Object, context);
            Votes entity = new Votes();

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

            await repository.Update(new Votes());

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

            modifiedRecord.Should().NotBeNull();
        }