示例#1
0
        public void GetProductsWithFiltration_PageNumberVeryBigNumber()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);
            List <TblProduct>  products           = productsRepository.GetProducts("", 1000, 1000, "");

            Assert.NotNull(products);
        }
示例#2
0
        public void GetProductsWithFiltration_KeyWordEmptyString()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);
            List <TblProduct>  productsEmpty      = productsRepository.GetProducts("");
            List <TblProduct>  productsAll        = productsRepository.GetProducts();

            Assert.Equal(productsEmpty, productsAll);
        }
示例#3
0
        public async System.Threading.Tasks.Task GetProductsWithFiltration_PageSizeButNoPageNumberAsync()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);
            List <TblProduct>  products           = productsRepository.GetProducts("", null, 20);
            int x = await dbContext.TblProduct.CountAsync();

            Assert.Equal(products.Count, x);
        }
示例#4
0
        public void GetProductsWithFiltration_CaseSensitive()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);
            List <TblProduct>  products_upper     = productsRepository.GetProducts("A");
            List <TblProduct>  products_lower     = productsRepository.GetProducts("a");

            Assert.Equal(products_upper, products_lower);
        }
        public async System.Threading.Tasks.Task DownLoadFile_NonexitingFile()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);
            ProductsService    productsService    = new ProductsService(productsRepository);
            var NonExistingFile = await productsService.DownloadFile(0);

            Assert.Null(NonExistingFile);
        }
        public async System.Threading.Tasks.Task CheckProductDataSheetAvailabilityAsync_NonExistingProduct()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);
            ProductsService    productsService    = new ProductsService(productsRepository);

            var NonExistingFile = await productsService.CheckProductDataSheetAvailabilityAsync(0);

            Assert.False(NonExistingFile);
        }
        public void GetProductById_NoneExistingId()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);
            ProductsService    productsService    = new ProductsService(productsRepository);

            var NonExistingFile = productsService.GetProductById(0);

            Assert.Null(NonExistingFile);
        }
示例#8
0
        public void GetProductDocumentsLastModified_NonExistingIds()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);

            List <TblProduct> productsAll = productsRepository.GetProducts().OrderBy(p => p.Id).ToList();
            var productDocumentAll        = productsRepository.GetProductDocumentsLastModified(productsAll.Select(p => p.Id).ToList());
            var fakeIds = new List <int> {
                productDocumentAll.Last().Key, productsAll.Last().Id + 1, productsAll.Last().Id + 2
            };
            var productDocument = productsRepository.GetProductDocumentsLastModified(fakeIds);

            Assert.Equal(1, productDocument.Count);
        }
        public async System.Threading.Tasks.Task CheckProductDataSheetAvailabilityAsync_NonExistingURL()
        {
            var options = new DbContextOptionsBuilder <ChemiCleanContext>()
                          .UseSqlServer(connectionString)
                          .Options;
            var dbContext = new ChemiCleanContext(options);

            ProductsRepository productsRepository = new ProductsRepository(dbContext);
            ProductsService    productsService    = new ProductsService(productsRepository);
            var product = productsRepository.GetProducts().FirstOrDefault();

            if (product != null)
            {
                product.Url = "None";
                productsRepository.Commit();
            }
            var NonExistingFile = await productsService.CheckProductDataSheetAvailabilityAsync(product.Id);

            Assert.False(NonExistingFile);
        }
 public ProductsRepository(ChemiCleanContext dbContext)
     : base(dbContext)
 {
 }
示例#11
0
 public BaseRepository(ChemiCleanContext dbContext)
 {
     _dbContext = dbContext;
 }