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

            Comment entity = new Comment();

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

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

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

            Comment entity = new Comment();

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 2, "B", 1);
            context.Set <Comment>().Add(entity);
            await context.SaveChangesAsync();

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

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

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }