示例#1
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();
        }
示例#2
0
        public async void Update_Entity_Is_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();

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }