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 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)); } }
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)); } }