本文整理匯總了C#中ToDoList.Task.GetId方法的典型用法代碼示例。如果您正苦於以下問題:C# Task.GetId方法的具體用法?C# Task.GetId怎麽用?C# Task.GetId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ToDoList.Task
的用法示例。
在下文中一共展示了Task.GetId方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Test_FindFindsTaskInDatabase
public void Test_FindFindsTaskInDatabase()
{
//Arrange
Task testTask = new Task("Mow the lawn");
testTask.Save();
//Act
Task foundTask = Task.Find(testTask.GetId());
//Assert
Assert.Equal(testTask, foundTask);
}
示例2: Test_Find_FindsTaskInDatabase
public void Test_Find_FindsTaskInDatabase()
{
//Arrange
DateTime fakeTime = new DateTime(2016, 1, 1);
Task testTask = new Task("Mow the lawn", 1, fakeTime);
testTask.Save();
//Act
Task foundTask = Task.Find(testTask.GetId());
//Assert
Assert.Equal(testTask, foundTask);
}
示例3: Test_SaveAssignsIdToObject
public void Test_SaveAssignsIdToObject()
{
//Arrange
Task testTask = new Task("Mow the lawn");
testTask.Save();
//Act
Task savedTask = Task.GetAll()[0];
int result = savedTask.GetId();
int testId = testTask.GetId();
//Assert
Assert.Equal(testId, result);
}
示例4: Test_Save_AssignsIdToObject
public void Test_Save_AssignsIdToObject()
{
//Arrange
DateTime fakeTime = new DateTime(2016, 1, 1);
Task testTask = new Task("Mow the lawn", 1, fakeTime);
//Act
testTask.Save();
Task savedTask = Task.GetAll()[0];
int result = savedTask.GetId();
int testId = testTask.GetId();
//Assert
Assert.Equal(testId, result);
}
示例5: AddTask
public void AddTask(Task newTask)
{
SqlConnection conn = DB.Connection();
conn.Open();
SqlCommand cmd = new SqlCommand("INSERT INTO categories_tasks(category_id,task_id) VALUES(@CategoryId,@TaskId);",conn);
SqlParameter categoryIdParameter = new SqlParameter();
categoryIdParameter.ParameterName = "@categoryId";
categoryIdParameter.Value=this.GetId();
cmd.Parameters.Add(categoryIdParameter);
SqlParameter taskIdParameter = new SqlParameter();
taskIdParameter.ParameterName="@TaskId";
taskIdParameter.Value=newTask.GetId();
cmd.Parameters.Add(taskIdParameter);
cmd.ExecuteNonQuery();
if(conn != null)
{
conn.Close();
}
}
示例6: AddTask
public void AddTask(Task newTask)
{
SqlConnection conn = DB.Connection();
conn.Open();
SqlDataReader rdrCheckForDuplicate = null;
SqlCommand cmdCheckForDuplicate = new SqlCommand("SELECT * FROM categories_tasks WHERE [email protected] AND [email protected]", conn);
SqlParameter categoryIdParameterCheckForDuplicate = new SqlParameter();
categoryIdParameterCheckForDuplicate.ParameterName = "@CategoryId";
categoryIdParameterCheckForDuplicate.Value = this.GetId();
cmdCheckForDuplicate.Parameters.Add(categoryIdParameterCheckForDuplicate);
SqlParameter taskIdParameterCheckForDuplicate = new SqlParameter();
taskIdParameterCheckForDuplicate.ParameterName = "@TaskId";
taskIdParameterCheckForDuplicate.Value = newTask.GetId();
cmdCheckForDuplicate.Parameters.Add(taskIdParameterCheckForDuplicate);
List<int> matchedJoins = new List<int> {};
rdrCheckForDuplicate = cmdCheckForDuplicate.ExecuteReader();
while(rdrCheckForDuplicate.Read())
{
matchedJoins.Add(rdrCheckForDuplicate.GetInt32(0));
}
if (rdrCheckForDuplicate != null) rdrCheckForDuplicate.Close();
if (matchedJoins.Count == 0)
{
SqlCommand cmd = new SqlCommand("INSERT INTO categories_tasks (category_id, task_id) VALUES (@CategoryId, @TaskId)", conn);
SqlParameter categoryIdParameter = new SqlParameter();
categoryIdParameter.ParameterName = "@CategoryId";
categoryIdParameter.Value = this.GetId();
cmd.Parameters.Add(categoryIdParameter);
SqlParameter taskIdParameter = new SqlParameter();
taskIdParameter.ParameterName = "@TaskId";
taskIdParameter.Value = newTask.GetId();
cmd.Parameters.Add(taskIdParameter);
cmd.ExecuteNonQuery();
}
if (conn != null)
{
conn.Close();
}
}
示例7: Test_FindFindsTaskInDatabase
public void Test_FindFindsTaskInDatabase()
{
//Arrange
Task testTask = new Task("Mow the lawn", new DateTime(2016, 2, 2), false);
testTask.Save();
//Act
Task result = Task.Find(testTask.GetId());
//Assert
Assert.Equal(testTask, result);
}
示例8: Test_Find_FindsTaskInDatabase
public void Test_Find_FindsTaskInDatabase()
{
DateTime testTime = new DateTime(2016, 1, 1);
Task testTask = new Task("Mow the lawn",testTime);
testTask.Save();
Task foundTask = Task.Find(testTask.GetId());
Assert.Equal(testTask, foundTask);
}