예제 #1
0
        public async void Create()
        {
            Mock <ILogger <ProductProductPhotoRepository> > loggerMoc = ProductProductPhotoRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductProductPhotoRepositoryMoc.GetContext();
            var repository = new ProductProductPhotoRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
예제 #2
0
        public async void Get()
        {
            Mock <ILogger <ProductProductPhotoRepository> > loggerMoc = ProductProductPhotoRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductProductPhotoRepositoryMoc.GetContext();
            var repository = new ProductProductPhotoRepository(loggerMoc.Object, context);

            ProductProductPhoto entity = new ProductProductPhoto();

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

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

            record.Should().NotBeNull();
        }
예제 #3
0
        public async void Delete()
        {
            Mock <ILogger <ProductProductPhotoRepository> > loggerMoc = ProductProductPhotoRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductProductPhotoRepositoryMoc.GetContext();
            var repository             = new ProductProductPhotoRepository(loggerMoc.Object, context);
            ProductProductPhoto entity = new ProductProductPhoto();

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

            await repository.Delete(entity.ProductID);

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

            modifiedRecord.Should().BeNull();
        }
예제 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ProductProductPhotoRepository> > loggerMoc = ProductProductPhotoRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductProductPhotoRepositoryMoc.GetContext();
            var repository             = new ProductProductPhotoRepository(loggerMoc.Object, context);
            ProductProductPhoto entity = new ProductProductPhoto();

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

            await repository.Update(new ProductProductPhoto());

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

            modifiedRecord.Should().NotBeNull();
        }