Пример #1
0
        public async void Create()
        {
            Mock <ILogger <ProductModelRepository> > loggerMoc = ProductModelRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductModelRepositoryMoc.GetContext();
            var repository = new ProductModelRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Пример #2
0
        public async void Get()
        {
            Mock <ILogger <ProductModelRepository> > loggerMoc = ProductModelRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductModelRepositoryMoc.GetContext();
            var repository = new ProductModelRepository(loggerMoc.Object, context);

            ProductModel entity = new ProductModel();

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

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

            record.Should().NotBeNull();
        }
Пример #3
0
        public async void Delete()
        {
            Mock <ILogger <ProductModelRepository> > loggerMoc = ProductModelRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductModelRepositoryMoc.GetContext();
            var          repository      = new ProductModelRepository(loggerMoc.Object, context);
            ProductModel entity          = new ProductModel();

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

            await repository.Delete(entity.ProductModelID);

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

            modifiedRecord.Should().BeNull();
        }
Пример #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ProductModelRepository> > loggerMoc = ProductModelRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductModelRepositoryMoc.GetContext();
            var          repository      = new ProductModelRepository(loggerMoc.Object, context);
            ProductModel entity          = new ProductModel();

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

            await repository.Update(new ProductModel());

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

            modifiedRecord.Should().NotBeNull();
        }