本文整理汇总了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);
}