public void TestGetNotebooksbyNotebookData()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Notebook nb  = CreateNotebook();
                Notebook nb2 = CreateNotebook2();
                Notebook nb3 = CreateNotebook3();
                db.AddNewNotebookToDatabase(nb);
                db.AddNewNotebookToDatabase(nb2);
                db.AddNewNotebookToDatabase(nb3);
                List <Product> notebooks = db.FindMatchingProducts(new NotebookQueryParams
                {
                    NotebookDataQueryParams = new NotebookDataQueryParams
                    {
                        batteryTimeRange = new OnlineShop.Range(950, 950),
                        notebookName     = "ASUS",
                        os             = OS.linux,
                        priceRange     = new OnlineShop.PriceRange(new Money(1), new Money(77000)),
                        ramMemoryRange = new OnlineShop.Range(32, 32),
                    }
                });
                Assert.That(notebooks[0].Name, Is.EqualTo(nb3.Name));
            }
        }
        public void TestAddNotebook()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Notebook nb = CreateNotebook();
                db.AddNewNotebookToDatabase(nb);
                Assert.That(() => db.AddNewNotebookToDatabase(nb), Throws.TypeOf <ProductAlreadyExistsException>());
                Assert.That(nb.Name, Is.EqualTo(db.GetNotebook(nb).Name));
            }
        }
        public void TestAddProduct()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Product p = new Product("NOTEBOOK", new Money(1000m));
                db.AddProductToDataBase(p);
                Assert.That(() => db.AddProductToDataBase(p), Throws.TypeOf <ProductAlreadyExistsException>());
                int productId = db.GetProductId(p);
                Assert.That(p.Name, Is.EqualTo(db.GetProduct(productId).Name));
            }
        }
        public void TestAddGraphic()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Graphic graphic = new Graphic(4, "NVIDIA GEFORCE 980TI");
                db.AddGraphicToDataBase(graphic);
                Assert.That(() => db.AddGraphicToDataBase(graphic), Throws.TypeOf <ProductAlreadyExistsException>());
                int graphicId = db.GetGraphicCardId(graphic);
                Assert.That(graphic.Name, Is.EqualTo(db.GetGraphicCard(graphicId).Name));
            }
        }
        public void TestAddCPU()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                CPU cpu = new CPU(numCores: 4, clockRateInGHZ: 2.5, name: "INTEL CORE i5 3200k");
                db.AddNewCpuToDatabase(cpu);
                Assert.That(() => db.AddNewCpuToDatabase(cpu), Throws.TypeOf <ProductAlreadyExistsException>());
                int cpuId = db.GetCpuId(cpu);
                Assert.That(cpu.Name, Is.EqualTo(db.GetCPU(cpuId).Name));
            }
        }
        public void TestAddHardDrive()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                HardDrive hardDrive = new HardDrive(1024, "ssd");
                db.AddNewHardDriveToDatabase(hardDrive);
                Assert.That(() => db.AddNewHardDriveToDatabase(hardDrive), Throws.TypeOf <ProductAlreadyExistsException>());
                int hardDriveId = db.GetHardDriveId(hardDrive);
                Assert.That(hardDrive.MemoryInGB, Is.EqualTo(db.GetHardDrive(hardDriveId).MemoryInGB));
                Assert.That(hardDrive.Type, Is.EqualTo(db.GetHardDrive(hardDriveId).Type));
            }
        }
        public void TestGetProducts()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Notebook nb = CreateNotebook();
                db.AddNewNotebookToDatabase(nb);
                List <Product> notebooks = db.FindMatchingProducts(new ProductQueryParams
                {
                    Price = new OnlineShop.PriceRange(new Money(1199.99m), new Money(1199.99m)),
                    Name  = "DELL GAMING NOTEBOOK",
                });
                Assert.That(notebooks[0].Name, Is.EqualTo(nb.Name));
            }
        }
        public void TestDeleteNotebook()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Notebook nb  = CreateNotebook();
                Notebook nb2 = CreateNotebook2();
                db.AddNewNotebookToDatabase(nb);
                db.AddNewNotebookToDatabase(nb2);
                db.DeleteCompleteNotebook(nb);
                db.DeleteCompleteNotebook(nb2);
                Assert.That(() => db.GetNotebook(nb), Throws.TypeOf <ProductNotFoundException>());
                Assert.That(() => db.GetCpuId(nb.Cpu), Throws.TypeOf <ProductNotFoundException>());
                Assert.That(() => db.GetGraphicCardId(nb.Graphic), Throws.TypeOf <ProductNotFoundException>());
                Assert.That(() => db.GetHardDriveId(nb.HardDrive), Throws.TypeOf <ProductNotFoundException>());
                Assert.That(() => db.GetProductId(nb), Throws.TypeOf <ProductNotFoundException>());
            }
        }
        public void TestGetNotebooksbyHardDrive()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Notebook nb  = CreateNotebook();
                Notebook nb2 = CreateNotebook2();
                Notebook nb3 = CreateNotebook3();
                db.AddNewNotebookToDatabase(nb);
                db.AddNewNotebookToDatabase(nb2);
                db.AddNewNotebookToDatabase(nb3);
                List <Product> notebooks = db.FindMatchingProducts(new NotebookQueryParams
                {
                    HardDriveQueryParams = new HardDriveQueryParams
                    {
                        hdType        = "ssd",
                        hdMemoryRange = new OnlineShop.Range(2048, 2048),
                    }
                });
                Assert.That(notebooks[0].Name, Is.EqualTo(nb3.Name));
            }
        }
        public void TestGetNotebooksbyGraphic()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Notebook nb  = CreateNotebook();
                Notebook nb2 = CreateNotebook2();
                Notebook nb3 = CreateNotebook3();
                db.AddNewNotebookToDatabase(nb);
                db.AddNewNotebookToDatabase(nb2);
                db.AddNewNotebookToDatabase(nb3);
                List <Product> notebooks = db.FindMatchingProducts(new NotebookQueryParams
                {
                    GraphicQueryParams = new GraphicQueryParams
                    {
                        graphicCardName = "NVIDIA GEFORCE 1080TI",
                        vramRange       = new OnlineShop.Range(4, 4),
                    }
                });
                Assert.That(notebooks[0].Name, Is.EqualTo(nb3.Name));
            }
        }
        public void TestGetNotebooksbyCPU()
        {
            var databasePath = MyTestSqliteDatabase.CreateTempPath();

            using (var db = new DatabaseFactory(new MyTestSqliteDatabase(databasePath)))
            {
                Notebook nb  = CreateNotebook();
                Notebook nb2 = CreateNotebook2();
                Notebook nb3 = CreateNotebook3();
                db.AddNewNotebookToDatabase(nb);
                db.AddNewNotebookToDatabase(nb2);
                db.AddNewNotebookToDatabase(nb3);
                List <Product> notebooks = db.FindMatchingProducts(new NotebookQueryParams
                {
                    CPUQueryParams = new CPUQueryParams
                    {
                        cpuName      = "INTEL",
                        cpuClockRate = new OnlineShop.Range(5.5, 5.5),
                        cpuCount     = new OnlineShop.Range(4, 4),
                    }
                });
                Assert.That(notebooks[0].Name, Is.EqualTo(nb3.Name));
            }
        }