Ejemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <ProductCostHistoryRepository> > loggerMoc = ProductCostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductCostHistoryRepositoryMoc.GetContext();
            var repository = new ProductCostHistoryRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Ejemplo n.º 2
0
        public async void Get()
        {
            Mock <ILogger <ProductCostHistoryRepository> > loggerMoc = ProductCostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductCostHistoryRepositoryMoc.GetContext();
            var repository = new ProductCostHistoryRepository(loggerMoc.Object, context);

            ProductCostHistory entity = new ProductCostHistory();

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

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

            record.Should().NotBeNull();
        }
Ejemplo n.º 3
0
        public async void Delete()
        {
            Mock <ILogger <ProductCostHistoryRepository> > loggerMoc = ProductCostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductCostHistoryRepositoryMoc.GetContext();
            var repository            = new ProductCostHistoryRepository(loggerMoc.Object, context);
            ProductCostHistory entity = new ProductCostHistory();

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

            await repository.Delete(entity.ProductID);

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

            modifiedRecord.Should().BeNull();
        }
Ejemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <ProductCostHistoryRepository> > loggerMoc = ProductCostHistoryRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ProductCostHistoryRepositoryMoc.GetContext();
            var repository            = new ProductCostHistoryRepository(loggerMoc.Object, context);
            ProductCostHistory entity = new ProductCostHistory();

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

            await repository.Update(new ProductCostHistory());

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

            modifiedRecord.Should().NotBeNull();
        }