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

            ProductReview entity = new ProductReview();

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

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

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

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }