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

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

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

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

            ProductPhoto entity = new ProductPhoto();

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

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

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

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

            await repository.Delete(entity.ProductPhotoID);

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

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

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

            await repository.Update(new ProductPhoto());

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

            modifiedRecord.Should().NotBeNull();
        }