Ejemplo n.º 1
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ProductCategoryRepository> > loggerMoc = ProductCategoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductCategoryRepositoryMoc.GetContext();
            var             repository   = new ProductCategoryRepository(loggerMoc.Object, context);
            ProductCategory entity       = new ProductCategory();

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

            await repository.Update(new ProductCategory());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Delete()
        {
            Mock <ILogger <ProductCategoryRepository> > loggerMoc = ProductCategoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductCategoryRepositoryMoc.GetContext();
            var             repository   = new ProductCategoryRepository(loggerMoc.Object, context);
            ProductCategory entity       = new ProductCategory();

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

            await repository.Delete(entity.ProductCategoryID);

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

            modifiedRecord.Should().BeNull();
        }