public override View GetView(int position, View convertView, ViewGroup parent) { View row = convertView; Prices price = productList[position]; if (row == null) { row = LayoutInflater.From(CurrentContext) .Inflate(Resource.Layout.productrowlayout, null, false); TextView productName = row.FindViewById <TextView>(Resource.Id.rowProductTitle); TextView productPrice = row.FindViewById <TextView>(Resource.Id.rowProductPrice); Button deleteButton = row.FindViewById <Button>(Resource.Id.deleteProductButton); productName.Text = productList[position].Name; productPrice.Text = "" + productList[position].Price + " kr."; deleteButton.Click += (object s, EventArgs e) => { TestCount++; //Toast.MakeText(row.Context, "Counts: " + TestCount, ToastLength.Short).Show(); DeleteHandler.Invoke(s, new DeleteEventArgs { ProductId = productList[position].ProductId }); }; } return(row); }
internal void Delete(ISerializableObject iso, ISerializerTransaction transaction) { if (!IsManaged(iso)) { return; } AttributeWorker w = AttributeWorker.GetInstance(Target); ResolverData <ISerializableObject> data = new ResolverData <ISerializableObject>(); data.FieldsToResolve = AttributeWorker.RetrieveAllFields(iso.GetType()); data.HandledItem = iso; DeleteHandler h = new DeleteHandler(this); RelationResolver <ISerializableObject> res = new RelationResolver <ISerializableObject>(); res.Handler = h; h.MODE = DeleteHandler.DOWNMODE; res.StartRelationResolving(data); _objectPool.DeleteObject(iso, _connection, transaction); h.MODE = DeleteHandler.UPMODE; res.StartRelationResolving(data); }
public HandlerProvider() { ImportHandler = new ImportHandler(); SearchHandler = new SearchHandler(); AutoCompleteHandler = new AutoCompleteHandler(); DeleteHandler = new DeleteHandler(); }
public static int Run(string[] args) { if (args.Length == 0 || args.Length == 1) { return(ErrorHandler.printHelpInfo()); } else { switch (args[1]) { case "new": return(NewHandler.PrintHelpMenu()); case "list": return(ListHandler.PrintHelpMenu()); case "update": return(UpdateHandler.PrintHelpMenu()); case "delete": return(DeleteHandler.PrintHelpMenu()); case "launch": return(LaunchHandler.PrintHelpMenu()); default: return(ErrorHandler.printHelpInfo()); } } }
public async void DeleteHandler_Should_Work(string id, bool expected) { // Given IMediator mediator = ServiceProvider.GetService <IMediator>(); MockEventPublisher publisher = new MockEventPublisher(mediator); MockSampleRepository repository = new MockSampleRepository( new Dictionary <string, Domain.Sample.Sample> { { "1", new Domain.Sample.Sample("1", "1") } }); Mock <IUnitOfWork> uow = new Mock <IUnitOfWork>(); Mock <ILogger <DeleteRequest> > logger = new Mock <ILogger <DeleteRequest> >(); DeleteHandler handler = new DeleteHandler(publisher, repository, uow.Object, logger.Object); DeleteRequest command = new DeleteRequest(id); // When Result result = await handler.Handle(command, new CancellationToken()); // Then List <ValidationResult> notValidNotifications = result.Notifications.Where(notification => !notification.IsValid).ToList(); if (expected) { Assert.Empty(notValidNotifications); } else { Assert.NotEmpty(notValidNotifications); } }
public override void Delete() { if (null != DeleteHandler) { DeleteHandler.Delete(); } }
public void DeleteHandler() { const string TEST_FOLDER_NAME = "TestFolderToDelete"; const string TEST_FOLDER_PATH = ROOT_TEST_PATH + "\\" + TEST_FOLDER_NAME; Directory.CreateDirectory(TEST_FOLDER_PATH); Assert.True(Directory.Exists(TEST_FOLDER_PATH)); var param = new DeleteParam { CurrentFolderPath = "/", Targets = new List <string> { TEST_FOLDER_NAME } }; var result = new DeleteHandler(CreateHostingEnv()).Run(param) as DeleteResult; PrintErrors(result.Errors); Assert.Equal(1, result.Affected); Assert.False(Directory.Exists(TEST_FOLDER_PATH)); Assert.True(result.Errors.Count == 0); }
public void Try_To_Delete_Invalid_User() { var deleteHandler = new DeleteHandler("../../../../TestFrameworklessApp/UnitTests/DeleteUserDatabaseTest.json"); var exception = Assert.Throws <ArgumentException>(() => deleteHandler.DeleteUser("8")); Assert.Equal("User does not exist", exception.Message); }
public void Execute() { _controller.Start(); DeleteHandler?.Delete(); Writer.Write(Read()); Updater.Update(); _controller.End(); }
public void Try_To_Delete_Bob() { var deleteHandler = new DeleteHandler("../../../../TestFrameworklessApp/UnitTests/DeleteUserDatabaseTest.json"); var exception = Assert.Throws <ArgumentException>(() => deleteHandler.DeleteUser("1")); Assert.Equal("Can not delete Bob", exception.Message); }
public SqlPersistenceProviderFactory(string connectionString, bool serializeAsText, TimeSpan lockTimeout) { this.ConnectionString = connectionString; this.LockTimeout = lockTimeout; this.SerializeAsText = serializeAsText; this.loadHandler = new LoadHandler(this); this.createHandler = new CreateHandler(this); this.updateHandler = new UpdateHandler(this); this.unlockHandler = new UnlockHandler(this); this.deleteHandler = new DeleteHandler(this); }
public DBAccess() { connection.DataSource = @"MSI"; //the data source of the connection connection.InitialCatalog = @"SENGroup25DB"; //the inital catalog of the connection connection.IntegratedSecurity = true; //the integrated security of the connection createDataHandler = new CreateHandler(connection.ToString()); deleteDataHandler = new DeleteHandler(connection.ToString()); readDataHandler = new ReadHandler(connection.ToString()); updateDataHandler = new UpdateHandler(connection.ToString()); }
public HttpResponseMessage Delete(int id) { var handler = new DeleteHandler(); var response = handler.Handle(id); if (handler.Errors == null || handler.Errors.Count < 1) { return(Request.CreateResponse(HttpStatusCode.OK, response.ReportComponentDtos[0])); } return(Request.CreateResponse(HttpStatusCode.BadRequest, handler.Errors)); }
public async Task HandleFunctionTest() { FakeData.InsertFakeData(this._context, 3); var request = new Delete(2); DeleteHandler handler = new DeleteHandler(this.unitOfWork, this.todoRepository); var result = await handler.Handle(request); Assert.Equal(ApplicationServiceStatus.Ok, result.Status); }
public void Execute() { _controller.Start(); DeleteHandler?.Delete(); if (Writer == null) { OutputProvider.Write(Read()); } else { Writer.Write(Read()); } Updater.Update(); _controller.End(); }
public void Delete(string entity, Guid id) { DeleteHandler.Execute(entity, id); var workflowInput = new WorkflowInputParameter(); workflowInput.Values.Add("Id", id); foreach (var item in DeleteWorkflows .Where(k => k.EntityLogicalName == entity) .OrderBy(k => k.Order)) { if (item.Action != null) { item.Action.Execute(this, workflowInput); } } }
public void DeleteHandler_AddAndSave() { var uow = new Mock <IUnitOfWork>(); uow.Setup(x => x.Find <Product>(1)).Returns(new Product() { Id = 1 }); var createOrUpdateCommandHandler = new DeleteHandler <int, Product>(uow.Object); createOrUpdateCommandHandler.Handle(1); uow.Verify(x => x.Find <Product>(1), Times.Once); uow.Verify(x => x.Delete(It.Is <Product>(y => y.Id == 1)), Times.Once); uow.Verify(x => x.Commit(), Times.Once); }
public void Add_One_User_To_Database() { var postHandler = new PostHandler("../../../../TestFrameworklessApp/UnitTests/PostHandlerDatabaseTest.json"); postHandler.AddUser("Tracy"); bool result = false; var actualList = DataController.GetData("../../../../TestFrameworklessApp/UnitTests/PostHandlerDatabaseTest.json"); foreach (var user in actualList) { if (user.Name.Equals("Tracy")) { result = true; var deleteHandler = new DeleteHandler("../../../../TestFrameworklessApp/UnitTests/PostHandlerDatabaseTest.json"); deleteHandler.DeleteUser("4"); } } Assert.True(result); }
public void Delete_A_User_From_Database() { var deleteHandler = new DeleteHandler("../../../../TestFrameworklessApp/UnitTests/DeleteUserDatabaseTest.json"); deleteHandler.DeleteUser("3"); var list = DataController.GetData("../../../../TestFrameworklessApp/UnitTests/DeleteUserDatabaseTest.json"); bool result = true; foreach (var user in list) { if (user.Id.Equals("3")) { result = false; } } list.Add(new User("Sam", "3")); DataController.SendData("../../../../TestFrameworklessApp/UnitTests/DeleteUserDatabaseTest.json", list); Assert.True(result); }
public SqlPersistenceProviderFactory(NameValueCollection parameters) { if (parameters == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("parameters"); } this.connectionString = null; this.LockTimeout = TimeSpan.Zero; this.SerializeAsText = false; foreach (string key in parameters.Keys) { switch (key) { case connectionStringNameParameter: ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[parameters[key]]; if (settings == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument( SR2.GetString(SR2.ConnectionStringNameIncorrect, parameters[key])); } this.connectionString = settings.ConnectionString; break; case serializeAsTextParameter: this.SerializeAsText = bool.Parse(parameters[key]); break; case lockTimeoutParameter: this.LockTimeout = TimeSpan.Parse(parameters[key], CultureInfo.InvariantCulture); break; default: throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument( key, SR2.GetString(SR2.UnknownSqlPersistenceConfigurationParameter, key, connectionStringNameParameter, serializeAsTextParameter, lockTimeoutParameter)); } } if (this.connectionString == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument( SR2.GetString(SR2.ConnectionStringNameParameterRequired, connectionStringNameParameter)); } this.loadHandler = new LoadHandler(this); this.createHandler = new CreateHandler(this); this.updateHandler = new UpdateHandler(this); this.unlockHandler = new UnlockHandler(this); this.deleteHandler = new DeleteHandler(this); }
internal void SendItemDeleted(object data) { // data is user inserted value with GenItem DeleteHandler?.Invoke(data); }
public Task <Result> Delete([FromQuery] bool error = false) => DeleteHandler.Handle(error);
private void HandleConnection(Socket sock) { NetworkStream stream = new NetworkStream(sock); string line = null; bool error = false; bool keepAlive = false; DateTime startTime = DateTime.Now; sock.ReceiveTimeout = RequestHandler.Timeout * 100; sock.Blocking = false; sock.NoDelay = true; sock.SendBufferSize = 16 * 1024; sock.UseOnlyOverlappedIO = true; string type = ""; string path = ""; do { bool first = true; RequestHandler handler = null; do { line = null; try { line = ReadLine(stream); BytesReadHeader += line.Length + 2; } catch (ThreadAbortException e) { keepAlive = false; error = true; break; } catch (IOException e) { keepAlive = false; error = true; break; } catch (Exception e) { keepAlive = false; error = true; break; } /* connection timed out or closed */ if (line == null) { sock.Close(); LogRequest(" (Socket closed)"); return; } if (first) { LogRequest(" (Connection from " + sock.RemoteEndPoint + ")"); } LogRequest("< " + line); /* not an empty line? */ if (line != "") { /* the first line contains the request */ if (first) { if (line.Contains(' ')) { type = line.Substring(0, line.IndexOf(' ')); path = line.Substring(line.IndexOf(' ')).Trim(); try { switch (type) { case "OPTIONS": handler = new OptionsHandler(this, path); break; case "PROPFIND": handler = new PropFindHandler(this, path); break; case "GET": handler = new GetHandler(this, path); break; case "HEAD": handler = new HeadHandler(this, path); break; case "PUT": handler = new PutHandler(this, path); break; case "LOCK": handler = new LockHandler(this, path); break; case "UNLOCK": handler = new UnlockHandler(this, path); break; case "DELETE": handler = new DeleteHandler(this, path); break; case "MOVE": handler = new MoveHandler(this, path); break; case "COPY": handler = new CopyHandler(this, path); break; case "MKCOL": handler = new MkColHandler(this, path); break; case "PROPPATCH": handler = new PropPatchHandler(this, path); break; default: handler = new RequestHandler(this, "/"); break; } } catch (IOException e) { Log("[i] Connection from " + sock.RemoteEndPoint + " (" + type + ") had IOException"); } catch (Exception e) { Log("[E] '" + e.GetType().ToString() + "' in connection from " + sock.RemoteEndPoint + " (" + type + ")"); } } first = false; } else { try { handler.AddHeaderLine(line); } catch (IOException e) { /* just close */ sock.Close(); LogRequest(" (Socket closed)"); return; } catch (Exception e) { Log("[E] '" + e.GetType().ToString() + "' in connection from " + sock.RemoteEndPoint + " (AddHeaderLine)"); } //stream.Flush(); } } } while (line != ""); if (handler == null) { Log("[E] Empty request in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); handler.KeepAlive = false; return; } if (!error) { try { if (handler.RequestContentLength > 0) { handler.HandleContent(stream); } handler.HandleRequest(stream); stream.Flush(); } catch (FileNotFoundException e) { Log("[E] 404 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); /* respond with error */ handler = new RequestHandler(this, "/"); handler.StatusCode = RequestHandler.GetStatusCode(404); handler.KeepAlive = false; handler.HandleRequest(stream); stream.Flush(); } catch (SocketException e) { Log("[E] '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); handler.KeepAlive = false; return; } catch (UnauthorizedAccessException e) { Log("[i] 403 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); /* respond with error */ handler = new RequestHandler(this, "/"); handler.StatusCode = RequestHandler.GetStatusCode(403); handler.KeepAlive = false; handler.HandleRequest(stream); stream.Flush(); } catch (Exception e) { Log("[E] 500 '" + e.GetType().ToString() + ": " + e.Message + "' in connection from " + sock.RemoteEndPoint + " (HandleContent/HandleRequest)"); /* respond with error */ handler = new RequestHandler(this, "/"); handler.StatusCode = RequestHandler.GetStatusCode(500); handler.KeepAlive = false; handler.HandleRequest(stream); stream.Flush(); } if (EnableRequestLog) { DateTime endTime = DateTime.Now; Log("[i] Connection from " + sock.RemoteEndPoint + " (" + type + " " + path + ") took " + (endTime - startTime).TotalMilliseconds + " ms (" + handler.StatusCode + ")"); } LogRequest(""); lock (StatisticsLock) { BytesWrittenHeader += handler.BytesWrittenHeader; BytesWrittenData += handler.BytesWrittenData; BytesReadHeader += handler.BytesReadHeader; BytesReadData += handler.BytesReadData; } keepAlive = handler.KeepAlive; /* windows isnt really using keepalive :( */ keepAlive = false; } } while (keepAlive); sock.Close(); LogRequest(" (Socket closed)"); }
void HandleDelete(RequestContext request) { string tmpString = DeleteHandler.HandleByCommand(request); ResponseHandler.Status200(Writer, tmpString); }
public DeleteHandlerTests() { _subject = new DeleteHandler(_taskRepository.Object); }
public void InvokeDeleteHandler(int position) { DeleteHandler?.Invoke(this, position); }