Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }
Exemplo n.º 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();
        }