public void Save() { Task3 TempTask = new Task3(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List <Task3> Tasks = new List <Task3>(); Task3 SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project3 TestProject = new Project3(); TestProject.ID = "A"; TestProject.Name = "Test Project"; List <Task3> Tasks3 = new List <Task3>(); Tasks3.Add(TempTask); TestProject.Tasks = Tasks3; TestProject.Save(); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM Project3_", CommandType.Text, "Data Source=localhost;Initial Catalog=ORMTestDatabase3;Integrated Security=SSPI;Pooling=false")) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal("", Helper.GetParameter <string>("Description_", "")); Assert.Equal("Test Project", Helper.GetParameter <string>("Name_", "")); } else { Assert.False(true, "Nothing was inserted"); } } using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM Task3_", CommandType.Text, "Data Source=localhost;Initial Catalog=ORMTestDatabase3;Integrated Security=SSPI;Pooling=false")) { Helper.ExecuteReader(); while (Helper.Read()) { Assert.Equal("This is a test", Helper.GetParameter <string>("Description_", "")); Assert.Contains(Helper.GetParameter <string>("Name_", ""), new string[] { "Sub task 1", "Sub task 3", "Sub task 3", "Test task" }); } } }
public void Any() { Task3 TempTask = new Task3(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List <Task3> Tasks = new List <Task3>(); Task3 SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project3 TestProject = new Project3(); TestProject.ID = "A"; TestProject.Name = "Test Project"; List <Task3> Tasks3 = new List <Task3>(); Tasks3.Add(TempTask); TestProject.Tasks = Tasks3; TestProject.Save(); Project3 TestObject = Project3.Any(new StringEqualParameter(TestProject.ID, "ID_", 100)); Assert.Equal(TestProject.ID, TestObject.ID); Assert.Equal(TestProject.Name, TestObject.Name); Assert.Equal(1, TestObject.Tasks.Count()); Assert.Equal("Test task", TestObject.Tasks.First().Name); Assert.Equal("This is a test", TestObject.Tasks.First().Description); foreach (Task3 TestSubTask in TestObject.Tasks.First().SubTasks) { Assert.Equal(0, TestSubTask.SubTasks.Count()); Assert.Contains(TestSubTask.Name, new string[] { "Sub task 1", "Sub task 3", "Sub task 3" }); Assert.Equal("This is a test", TestSubTask.Description); Assert.Equal(new DateTime(1900, 1, 1), TestSubTask.DueDate); } }
public void All() { Task3 TempTask = new Task3(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List <Task3> Tasks = new List <Task3>(); Task3 SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project3 TestProject = new Project3(); TestProject.ID = "A"; TestProject.Name = "Test Project"; List <Task3> Tasks3 = new List <Task3>(); Tasks3.Add(TempTask); TestProject.Tasks = Tasks3; TestProject.Save(); IEnumerable <Task3> TestObject = Task3.All(); foreach (Task3 TestTask in TestObject) { Assert.Contains(TestTask.Name, new string[] { "Sub task 1", "Sub task 3", "Sub task 3", "Test task" }); Assert.Equal("This is a test", TestTask.Description); Assert.Equal(new DateTime(1900, 1, 1), TestTask.DueDate); } }
public void All() { Task3 TempTask = new Task3(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List<Task3> Tasks = new List<Task3>(); Task3 SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project3 TestProject = new Project3(); TestProject.ID = "A"; TestProject.Name = "Test Project"; List<Task3> Tasks3 = new List<Task3>(); Tasks3.Add(TempTask); TestProject.Tasks = Tasks3; TestProject.Save(); IEnumerable<Task3> TestObject = Task3.All(); foreach (Task3 TestTask in TestObject) { Assert.Contains(TestTask.Name, new string[] { "Sub task 1", "Sub task 3", "Sub task 3", "Test task" }); Assert.Equal("This is a test", TestTask.Description); Assert.Equal(new DateTime(1900, 1, 1), TestTask.DueDate); } }
public void Any() { Task3 TempTask = new Task3(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List<Task3> Tasks = new List<Task3>(); Task3 SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project3 TestProject = new Project3(); TestProject.ID = "A"; TestProject.Name = "Test Project"; List<Task3> Tasks3 = new List<Task3>(); Tasks3.Add(TempTask); TestProject.Tasks = Tasks3; TestProject.Save(); Project3 TestObject = Project3.Any(new StringEqualParameter(TestProject.ID, "ID_", 100)); Assert.Equal(TestProject.ID, TestObject.ID); Assert.Equal(TestProject.Name, TestObject.Name); Assert.Equal(1, TestObject.Tasks.Count()); Assert.Equal("Test task", TestObject.Tasks.First().Name); Assert.Equal("This is a test", TestObject.Tasks.First().Description); foreach (Task3 TestSubTask in TestObject.Tasks.First().SubTasks) { Assert.Equal(0, TestSubTask.SubTasks.Count()); Assert.Contains(TestSubTask.Name, new string[] { "Sub task 1", "Sub task 3", "Sub task 3" }); Assert.Equal("This is a test", TestSubTask.Description); Assert.Equal(new DateTime(1900, 1, 1), TestSubTask.DueDate); } }
public void Update() { Task3 TempTask = new Task3(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List<Task3> Tasks = new List<Task3>(); Task3 SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); SubTask = new Task3(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project3 TestProject = new Project3(); TestProject.ID = "A"; TestProject.Name = "Test Project"; List<Task3> Tasks3 = new List<Task3>(); Tasks3.Add(TempTask); TestProject.Tasks = Tasks3; TestProject.Save(); TestProject.Name = "Test description3"; TestProject.Save(); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM Project3_", CommandType.Text, "Data Source=localhost;Initial Catalog=ORMTestDatabase3;Integrated Security=SSPI;Pooling=false")) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal("", Helper.GetParameter<string>("Description_", "")); Assert.Equal("Test description3", Helper.GetParameter<string>("Name_", "")); } else { Assert.False(true, "Nothing was inserted"); } } using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM Task3_", CommandType.Text, "Data Source=localhost;Initial Catalog=ORMTestDatabase3;Integrated Security=SSPI;Pooling=false")) { Helper.ExecuteReader(); while (Helper.Read()) { Assert.Equal("This is a test", Helper.GetParameter<string>("Description_", "")); Assert.Contains(Helper.GetParameter<string>("Name_", ""), new string[] { "Sub task 1", "Sub task 3", "Sub task 3", "Test task" }); } } }