public void Save() { Task2 TempTask = new Task2(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List <Task2> Tasks = new List <Task2>(); Task2 SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 2"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project2 TestProject = new Project2(); TestProject.Description = "This is a test project"; TestProject.Name = "Test Project"; List <Task2> Tasks2 = new List <Task2>(); Tasks2.Add(TempTask); TestProject.Tasks = Tasks2; TestProject.Save(); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM Project2_", CommandType.Text, "Data Source=localhost;Initial Catalog=ORMTestDatabase3;Integrated Security=SSPI;Pooling=false")) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal("This is a test project", 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 Task2_", 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 2", "Sub task 3", "Test task" }); } } }
public void Any() { Task2 TempTask = new Task2(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List <Task2> Tasks = new List <Task2>(); Task2 SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 2"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project2 TestProject = new Project2(); TestProject.Description = "This is a test project"; TestProject.Name = "Test Project"; List <Task2> Tasks2 = new List <Task2>(); Tasks2.Add(TempTask); TestProject.Tasks = Tasks2; TestProject.Save(); Project2 TestObject = Project2.Any(new EqualParameter <long>(TestProject.ID, "ID_")); Assert.Equal(TestProject.Description, TestObject.Description); 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 (Task2 TestSubTask in TestObject.Tasks.First().SubTasks) { Assert.Equal(0, TestSubTask.SubTasks.Count()); Assert.Contains(TestSubTask.Name, new string[] { "Sub task 1", "Sub task 2", "Sub task 3" }); Assert.Equal("This is a test", TestSubTask.Description); Assert.Equal(new DateTime(1900, 1, 1), TestSubTask.DueDate); } }
public void All() { Task2 TempTask = new Task2(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List <Task2> Tasks = new List <Task2>(); Task2 SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 2"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project2 TestProject = new Project2(); TestProject.Description = "This is a test project"; TestProject.Name = "Test Project"; List <Task2> Tasks2 = new List <Task2>(); Tasks2.Add(TempTask); TestProject.Tasks = Tasks2; TestProject.Save(); IEnumerable <Task2> TestObject = Task2.All(); foreach (Task2 TestTask in TestObject) { Assert.Contains(TestTask.Name, new string[] { "Sub task 1", "Sub task 2", "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() { Task2 TempTask = new Task2(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List<Task2> Tasks = new List<Task2>(); Task2 SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 2"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project2 TestProject = new Project2(); TestProject.Description = "This is a test project"; TestProject.Name = "Test Project"; List<Task2> Tasks2 = new List<Task2>(); Tasks2.Add(TempTask); TestProject.Tasks = Tasks2; TestProject.Save(); IEnumerable<Task2> TestObject = Task2.All(); foreach (Task2 TestTask in TestObject) { Assert.Contains(TestTask.Name, new string[] { "Sub task 1", "Sub task 2", "Sub task 3", "Test task" }); Assert.Equal("This is a test", TestTask.Description); Assert.Equal(new DateTime(1900, 1, 1), TestTask.DueDate); } }
public void Update() { Task2 TempTask = new Task2(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List<Task2> Tasks = new List<Task2>(); Task2 SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 2"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project2 TestProject = new Project2(); TestProject.Description = "This is a test project"; TestProject.Name = "Test Project"; List<Task2> Tasks2 = new List<Task2>(); Tasks2.Add(TempTask); TestProject.Tasks = Tasks2; TestProject.Save(); TestProject.Description = "Test description2"; TestProject.Save(); using (Utilities.SQL.SQLHelper Helper = new Utilities.SQL.SQLHelper("SELECT * FROM Project2_", "Data Source=localhost;Initial Catalog=ORMTestDatabase3;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { Helper.ExecuteReader(); if (Helper.Read()) { Assert.Equal("Test description2", 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 Task2_", "Data Source=localhost;Initial Catalog=ORMTestDatabase3;Integrated Security=SSPI;Pooling=false", CommandType.Text)) { 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 2", "Sub task 3", "Test task" }); } } }
public void Any() { Task2 TempTask = new Task2(); TempTask.Description = "This is a test"; TempTask.DueDate = new DateTime(1900, 1, 1); TempTask.Name = "Test task"; List<Task2> Tasks = new List<Task2>(); Task2 SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 1"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 2"; Tasks.Add(SubTask); SubTask = new Task2(); SubTask.Description = "This is a test"; SubTask.DueDate = new DateTime(1900, 1, 1); SubTask.Name = "Sub task 3"; Tasks.Add(SubTask); TempTask.SubTasks = Tasks; Project2 TestProject = new Project2(); TestProject.Description = "This is a test project"; TestProject.Name = "Test Project"; List<Task2> Tasks2 = new List<Task2>(); Tasks2.Add(TempTask); TestProject.Tasks = Tasks2; TestProject.Save(); Project2 TestObject = Project2.Any(new EqualParameter<long>(TestProject.ID, "ID_")); Assert.Equal(TestProject.Description, TestObject.Description); 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 (Task2 TestSubTask in TestObject.Tasks.First().SubTasks) { Assert.Equal(0, TestSubTask.SubTasks.Count()); Assert.Contains(TestSubTask.Name, new string[] { "Sub task 1", "Sub task 2", "Sub task 3" }); Assert.Equal("This is a test", TestSubTask.Description); Assert.Equal(new DateTime(1900, 1, 1), TestSubTask.DueDate); } }