public void FindByAssigneePersonTest() { // Arrange People people = new People(); TodoItems todo = new TodoItems(); PersonSequencer.Reset(); TodoSequencer.Reset(); Person lasse = people.NewPerson("Lasse", "Nääf"); Person albin = people.NewPerson("Albin", "Ek"); Todo job1 = todo.NewTodoItem("Do this", false, lasse); Todo job2 = todo.NewTodoItem("Do this", true, lasse); Todo job3 = todo.NewTodoItem("Do this", true, albin); // Act Todo[] actual = todo.FindByAssignee(lasse); //uses person object as parameter Todo[] actual2 = todo.FindByAssignee(albin); // Assert Assert.True(actual.Length == 2); Assert.True(actual2.Length == 1); Assert.Contains(job1, actual); Assert.Contains(job2, actual); Assert.Contains(job3, actual2); }
public void TestFindByAssigneePersonID() { //Arrange Person TestPerson = new Person("Ärling", "Ärman"); arrayOfItemsV1.CreateANewTodoItem("Ärling HAR satt upp lampor", true, TestPerson); arrayOfItemsV1.CreateANewTodoItem("Ärling SKA ta ner lampor", false, TestPerson); //Act //Todo[] assigneeTodo = TodoItems.FindByAssignee(TestPerson); Todo[] assigneeTodo = arrayOfItemsV1.FindByAssignee(TestPerson.PersonalId); //Asset Assert.True(TestPerson == assigneeTodo[0].assignee && assigneeTodo.Length > 1); //vi skall ha minst två todo }
public void TodoItems_TestCase_10c() { //Arrange int matchingPersonID = 0; Todo[] allMatchingToDo; TodoItems todoItems = new TodoItems(); Todo todo1 = new Todo("First Todo"); Todo todo2 = new Todo("Second Todo"); Todo todo3 = new Todo("Third Todo"); Person p1 = new Person(1, "TestPerson", "Lname1"); Person p2 = new Person(2, "AnyPerson", "Lname2"); Person p3 = new Person(3, "FailPerson", "Lname3"); //Act todo1.Assignee = p1; todo2.Assignee = p2; todo3.Assignee = p1; todoItems.addToDoToTodoItemsArray(todo1); todoItems.addToDoToTodoItemsArray(todo2); todoItems.addToDoToTodoItemsArray(todo3); allMatchingToDo = todoItems.FindByAssignee(p1); matchingPersonID = p1.PersonId; //Assert foreach (Todo td in allMatchingToDo) { Assert.Equal(matchingPersonID, td.Assignee.PersonId); } }
public void RunFindByAssigneeAssignee() { //Arrange TodoItems tasks = new TodoItems(); People people = new People(); PersonSequencer.Reset(); TodoSequencer.Reset(); tasks.Clear(); people.Clear(); Person firstPerson = people.NewPerson("Anders", "Karlsson"); Person secondPerson = people.NewPerson("Bengt", "Andersson"); Todo firstTodo = tasks.NewTodo("Cleaning floor"); Todo secondTodo = tasks.NewTodo("Making clear code"); firstTodo.Assignee = firstPerson; //secondTodo.Assignee = secondPerson; Todo[] newArray = new Todo[0]; //Act Todo[] actual = tasks.FindByAssignee(firstTodo.Assignee); //Assert Assert.NotEqual(newArray, actual); }
public void FindByAssigneePerson_NullPerson_ReturnsUnassignedItems() { //findbyAssignee(null) will return the unassigned items //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee1 = new Person(personId, firstName, familyName); personId = PersonSequencer.nextPersonId(); Person assignee2 = new Person(personId, "Klara", familyName); Person assignee3 = null; string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; string description3 = "Promenera"; //TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee1, description1); todoItems.AddToDoItem(assignee2, description2); todoItems.AddToDoItem(assignee3, description3); //act Todo[] foundItemsArray = todoItems.FindByAssignee(assignee3); //assert Assert.Single(foundItemsArray); }
public void FindByAssigneeInt_NotFound_Arraysize0() { //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Gå ut med hunden"; string description2 = "Kela med katten"; string description3 = "Promenera"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(null, description3); //act Todo[] foundItemsArray = todoItems.FindByAssignee(personId + 10); //assert Assert.Empty(foundItemsArray); }
public void TestFindBytodoItem() { //Arrange Person person = new Person(1856, "Garan", "Persson"); TodoItems todoItem = new TodoItems(); todoItem.Clear(); todoItem.NewTodo("hahaha"); //0 todoItem.NewTodo("Some stuff to do"); //1 todoItem.NewTodo("Hohoho"); //2 Todo[] allTodos = todoItem.FindAll(); allTodos[1].Assignee = person; //act Todo[] allAssignee = todoItem.FindByAssignee(person); Todo[] Unsigneed = todoItem.FindUnassignedTodoItem(); //Assert Assert.Equal("Some stuff to do", allAssignee[0].Description); Assert.Null(Unsigneed[0].Assignee); Assert.Null(Unsigneed[1].Assignee); }
public void FindByAssignee() { // Arrange TodoItems todoItems = new TodoItems(); todoItems.Clear(); todoItems.CreateTodo("A description"); todoItems.CreateTodo("Another description"); Todo[] allTodos = todoItems.FindAll(); // Act Person person = new Person(12, "Sam ", "Anderson"); allTodos[1].Assignee = person; Todo[] assignedTodos = todoItems.FindByAssignee(person); // Assert Assert.Equal(allTodos[1], assignedTodos[0]); Assert.Single(assignedTodos); }
public void FindByAssigneeStatusOverload_Ok() { //Arrange Todo todo1 = TodoItems.AddNewTodo("Eat a pizza"); Todo todo2 = TodoItems.AddNewTodo("Buy another salad"); Todo todo3 = TodoItems.AddNewTodo("Get a tea"); Todo todo4 = TodoItems.AddNewTodo("Send mom a bottle"); //Act Person todoPerson = People.AddNewPerson("Adam", "Tuckerberg"); Todo[] todoArray = TodoItems.FindAll(); todoArray[0].Assignee = todoPerson; todoArray[2].Assignee = todoPerson; Todo[] findByAssigneeArray = TodoItems.FindByAssignee(todoPerson); //Assert Assert.Equal(todoPerson, findByAssigneeArray[0].Assignee); Assert.Equal(todoPerson, findByAssigneeArray[1].Assignee); }
public void FindByAssigneeStatus_Ok() { //Arrange Todo todo1 = TodoItems.AddNewTodo("Eat a burger"); Todo todo2 = TodoItems.AddNewTodo("Buy another beer"); Todo todo3 = TodoItems.AddNewTodo("Get a coffee"); Todo todo4 = TodoItems.AddNewTodo("Send dad a bottle"); //Act Person todoPerson = People.AddNewPerson("Bengan", "Anderssen"); Todo[] todoArray = TodoItems.FindAll(); todoArray[0].Assignee = todoPerson; todoArray[2].Assignee = todoPerson; Todo[] findByAssigneeArray = TodoItems.FindByAssignee(todoPerson.PersonId); //Assert Assert.Equal(todoPerson, findByAssigneeArray[0].Assignee); Assert.Equal(todoPerson, findByAssigneeArray[1].Assignee); }
public void FindByAssignee_TestThatATodoObjectWithNoAssigneeIsFoundAndReturned() { //Arrange string todo_1_description = "Code a calculator application"; string todo_2_description = "Code a Todo application"; string todo_3_description = "Code a Hangman application"; string person_1_Firstname = "Neri"; string person_1_Lastname = "Chris"; string person_2_Firstname = "Joey"; string person_2_Lastname = "Ken"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); People people = new People(); Person person_1 = people.CreatePerson(person_1_Firstname, person_1_Lastname); Person person_2 = people.CreatePerson(person_2_Firstname, person_2_Lastname); Todo todo_1 = todoItems.CreateTodo(todo_1_description); todo_1.Assignee = null; Todo todo_2 = todoItems.CreateTodo(todo_2_description); todo_2.Assignee = person_2; Todo todo_3 = todoItems.CreateTodo(todo_3_description); todo_3.Assignee = person_2; Todo[] expected = { todo_1 }; //Act Todo[] result = todoItems.FindByAssignee(null); //Assert Assert.Equal(expected, result); }
public void FindByAssignee() { TodoItems todoItems = new TodoItems(); todoItems.Clear(); TodoSeqencer.reset(); todoItems.Newtodo("Run"); todoItems.Newtodo("Eat"); todoItems.Newtodo("Sleep"); todoItems.Newtodo("work"); Person person1 = new Person(1, "Haris", "Gusinac"); Person person2 = new Person(2, "Pontus", "Eriksson"); todoItems.FindById(1).Assignee = person1; todoItems.FindById(2).Assignee = person2; todoItems.FindById(4).Assignee = person2; Todo[] todoAssigneePerson2 = todoItems.FindByAssignee(person2); Assert.Equal(2, todoAssigneePerson2.Length); }
public void RunFindByAssigneePersonId() { //Arange TodoItems tasks = new TodoItems(); People people = new People(); PersonSequencer.Reset(); TodoSequencer.Reset(); tasks.Clear(); people.Clear(); Person firstPerson = people.NewPerson("Anders", "Karlsson"); Person secondPerson = people.NewPerson("Bengt", "Andersson"); Todo firstTodo = tasks.NewTodo("Cleaning floor"); Todo secondTodo = tasks.NewTodo("Making clear code"); firstTodo.Assignee = firstPerson; secondTodo.Assignee = secondPerson; Todo[] newArray = new Todo[1] { firstTodo }; //Act Todo[] actual = tasks.FindByAssignee(2); //Assert Assert.NotEqual(newArray, actual); // Cannot see the person object in test results // Assert.Equal(newArray, actual); }