public void ApiController_Delete_API_RemoveNotAllowedFile_Test() { // re add data var createAnImage = InsertSearchData(); // Clean existing items to avoid errors var itemByHash = _query.SingleItem(createAnImage.FilePath); itemByHash.FileIndexItem.Tags = string.Empty; _query.UpdateItem(itemByHash.FileIndexItem); _appSettings.DatabaseType = AppSettings.DatabaseTypeList.InMemoryDatabase; var selectorStorage = new FakeSelectorStorage(new StorageSubPathFilesystem(_appSettings, new FakeIWebLogger())); var deleteItem = new DeleteItem(_query, _appSettings, selectorStorage); var controller = new DeleteController(deleteItem); var notFoundResult = controller.Delete(createAnImage.FilePath) as NotFoundObjectResult; Assert.AreEqual(404, notFoundResult.StatusCode); var jsonCollection = notFoundResult.Value as List <FileIndexItem>; Assert.AreEqual(FileIndexItem.ExifStatus.OperationNotSupported, jsonCollection.FirstOrDefault().Status); _query.RemoveItem(_query.SingleItem(createAnImage.FilePath).FileIndexItem); }
public void ApiController_Delete_API_HappyFlow_Test() { var createAnImage = InsertSearchData(true); _appSettings.DatabaseType = AppSettings.DatabaseTypeList.InMemoryDatabase; // RealFs Storage var selectorStorage = new FakeSelectorStorage(new StorageSubPathFilesystem(_appSettings, new FakeIWebLogger())); var deleteItem = new DeleteItem(_query, _appSettings, selectorStorage); var controller = new DeleteController(deleteItem); Console.WriteLine("createAnImage.FilePath"); Console.WriteLine(createAnImage.FilePath); new CreateAnImage(); var actionResult = controller.Delete(createAnImage.FilePath) as JsonResult; Assert.AreNotEqual(actionResult, null); var jsonCollection = actionResult.Value as List <FileIndexItem>; Assert.AreEqual(createAnImage.FilePath, jsonCollection.FirstOrDefault().FilePath); new CreateAnImage(); //restore afterwards }
private void btnDelete_Click(object sender, EventArgs e) { string _menus = GlobalVar.TabSelected; DeleteController ic = new DeleteController(); DialogResult result1; OBJSQL obj = null; switch (_menus) { case "Barang": result1 = XtraMessageBox.Show("Are you sure you want to delete ? ", "Important Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { obj = ic.Delete("m_barang", "kode", _Barang.kodeBarang); _Barang.loadBarang(); } break; case "Supplier": result1 = XtraMessageBox.Show("Are you sure you want to delete ? ", "Important Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { obj = ic.Delete("m_supplier", "kode", _Supplier.kodeSupplier); _Supplier.loadSupplier(); } break; case "Pelanggan": result1 = XtraMessageBox.Show("Are you sure you want to delete ? ", "Important Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result1 == DialogResult.Yes) { obj = ic.Delete("m_pelanggan", "kode", _Pelanggan.kodePelanggan); _Pelanggan.loadPelanggan(); } break; } }
public void ApiController_Delete_SourceImageMissingOnDisk_WithFakeExiftool() { _query.AddItem(new FileIndexItem { FileName = "345678765434567.jpg", ParentDirectory = "/", FileHash = "345678765434567" }); var selectorStorage = new FakeSelectorStorage(new StorageSubPathFilesystem(_appSettings, new FakeIWebLogger())); var deleteItem = new DeleteItem(_query, _appSettings, selectorStorage); var controller = new DeleteController(deleteItem); var notFoundResult = controller.Delete("/345678765434567.jpg") as NotFoundObjectResult; Assert.AreEqual(404, notFoundResult.StatusCode); _query.RemoveItem(_query.SingleItem("/345678765434567.jpg").FileIndexItem); }