public void TaskDTest() { Assert.Equal(1, TaskD.FindSolution(Array.ConvertAll("3 5 1 4 6 6".Split(), int.Parse))); Assert.Equal(3, TaskD.FindSolution(Array.ConvertAll("1 2 3".Split(), int.Parse))); Assert.Equal(3, TaskD.FindSolution(Array.ConvertAll("1 3 3 4".Split(), int.Parse))); Assert.Equal(10, TaskD.FindSolution(Array.ConvertAll("1 6 3 4 5 6".Split(), int.Parse))); }
public static LinkedList <TaskD> Open(string author, string boardName) { string connetion_string = null; string database_name = "MyDatabase.sqlite"; SQLiteConnection connection; SQLiteCommand command; connetion_string = $"Data Source={database_name};Version=3;"; connection = new SQLiteConnection(connetion_string); SQLiteDataReader dataReader; LinkedList <TaskD> listTaskD = new LinkedList <TaskD>(); TaskD taskD = null; try { connection.Open(); string sql = "select * from TaskTable WHERE BoardName = '" + boardName + "' AND Author ='" + author + "'"; command = new SQLiteCommand(sql, connection); dataReader = command.ExecuteReader(); while (dataReader.Read()) { //if (((int)((long)dataReader["TaskID"]))==taskID) { string titleD = (string)dataReader.GetValue(0); string descriptionD = (string)dataReader.GetValue(1); int statusD = (int)((long)dataReader.GetValue(2)); string dueDateD = (string)dataReader.GetValue(3); string creationDateD = (string)dataReader.GetValue(4); string authorD = (string)dataReader.GetValue(5); int taskIDD = (int)((long)dataReader.GetValue(6)); string boardNameD = (string)dataReader.GetValue(7); taskD = new TaskD(titleD, descriptionD, statusD, dueDateD, creationDateD, authorD, taskIDD, boardNameD); listTaskD.AddLast(taskD); } } dataReader.Close(); command.Dispose(); Log.Info("the tasks in board: " + boardName + "of the user: "******"opened successfuly"); return(listTaskD); } catch (Exception ex) { Log.Error("Failed to open the tasks in board: " + boardName + "of the user: " + author); return(null); } finally { connection.Close(); } }