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 FindUnassignedTest() { // 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); Todo jobRight = todo.NewTodoItem("This is the one"); Todo jobRight2 = todo.NewTodoItem("This is the other one"); // Act Todo[] actual = todo.FindUnassignedTodoItems(); // Assert Assert.True(actual.Length == 2); Assert.Contains(jobRight, actual); Assert.Contains(jobRight2, actual); Assert.DoesNotContain(job1, actual); Assert.DoesNotContain(job2, actual); Assert.DoesNotContain(job3, actual); }
public void PeopleFindbyIdTest() { // Arrange int personId = 1; int personId2 = 2; int personId3 = 3; People people = new People(); PersonSequencer.Reset(); people.NewPerson("Lasse", "Nääf"); people.NewPerson("Nils", "Korv"); // Act Person actual = people.FindById(personId); Person actual2 = people.FindById(personId2); Person actual3 = people.FindById(personId3); // Assert //person1 //checks if both names is contained in object, then check if expected ID is right Assert.Contains("Lasse", actual.PersonInformation()); Assert.Contains("Nääf", actual.PersonInformation()); Assert.Contains(personId.ToString(), actual.PersonInformation()); //person2 Assert.Contains("Nils", actual2.PersonInformation()); Assert.Contains("Korv", actual2.PersonInformation()); Assert.Contains(personId2.ToString(), actual2.PersonInformation()); Assert.True(actual3 == null);//control to make sure only two people exists in array }
public void FindByDoneStatusTest() { // Arrange People people = new People(); TodoItems todo = new TodoItems(); PersonSequencer.Reset(); TodoSequencer.Reset(); Person lasse = people.NewPerson("Lasse", "Nääf"); Person nils = people.NewPerson("Nils", "Korv"); Person albin = people.NewPerson("Albin", "Ek"); Todo job1 = todo.NewTodoItem("Do this", false, lasse);// sets false to check that it is excluded in method Todo job2 = todo.NewTodoItem("Do this", true, nils); Todo job3 = todo.NewTodoItem("Do this", true, albin); // Act Todo[] actual = todo.FindByDoneStatus(); // Assert Assert.True(actual.Length == 2);// checks that its actually two objects instead of three Assert.Contains(job2, actual); Assert.Contains(job3, actual); Assert.DoesNotContain(job1, actual); }
public void FindUnassigned_FindOnlyOne_Arraysize1() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); personId = PersonSequencer.getNext(); Person assignee2 = new Person(personId, "Clara", familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee2, description2); todoItems.AddToDoItem(null, description3); //act ToDo[] foundItemsArray = todoItems.FindUnassignedTodoItems(); //assert Assert.Single(foundItemsArray); Assert.Equal(description3, foundItemsArray[0].Description); }
public void FindAllItems_FindsAll_ArraySizeOK() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Peter"; string familyName = "Jansson"; Person assignee = new Person(personId, firstName, familyName); int expectedSizeOfToDoItems = 3; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(null, description3); //act ToDo[] itemArray = todoItems.FindAll(); //assert Assert.Equal(expectedSizeOfToDoItems, itemArray.Length); }
public void FindByAssigneePerson_NullPerson_ReturnsUnassignedItems() { //findbyAssignee(null) will return the unassigned items //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee1 = new Person(personId, firstName, familyName); personId = PersonSequencer.getNext(); Person assignee2 = new Person(personId, "Clara", familyName); Person assignee3 = null; string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; //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.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; 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 FindByDoneStatus_FindOnlyNotDone_Arraysize3() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; string description3 = "Take a walk."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 3 not done todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(assignee, description3); //set one of the items to done. ToDo itemToBeDone = todoItems.FindById(1); itemToBeDone.Done = true; //act ToDo[] foundItemsArray = todoItems.FindByDoneStatus(false); //assert Assert.Equal(2, foundItemsArray.Length); }
public void RemovePersonTest() { // Arrange People people = new People(); PersonSequencer.Reset(); int expected = 3; int personId = 3; int personId2 = 1; Person lasse = people.NewPerson("Lasse", "Nääf"); Person albin = people.NewPerson("Albin", "Ek"); Person robert = people.NewPerson("Robert", "Lönn"); Person elroy = people.NewPerson("Elroy", "Bok"); Person lina = people.NewPerson("Lina", "Qvist"); // Act people.RemovePerson(personId); people.RemovePerson(personId2); int size = people.Size(); Person[] actual = people.FindAll(); // Assert //same as previous test but two removed this time Assert.Equal(expected, size); Assert.DoesNotContain(lasse, actual); Assert.Contains(albin, actual); Assert.DoesNotContain(robert, actual); Assert.Contains(elroy, actual); Assert.Contains(lina, actual); }
public void FindByIdTest() { Person person; People personList = new People(); personList.ClearPersons(); PersonSequencer.reset(); personList.NewPerson("Pelle", "Plätt"); personList.NewPerson("Kenny", "Starfighter"); personList.NewPerson("Ebbot", "Lavén"); person = personList.FindById(1); Assert.Equal("Pelle", person.FirstName); Assert.Equal("Plätt", person.LastName); Assert.Equal(1, person.PersonID); person = personList.FindById(2); Assert.Equal("Kenny", person.FirstName); Assert.Equal("Starfighter", person.LastName); Assert.Equal(2, person.PersonID); person = personList.FindById(3); Assert.Equal("Ebbot", person.FirstName); Assert.Equal("Lavén", person.LastName); Assert.Equal(3, person.PersonID); }
public void Remove_RemoveOneNotIncluded_NothingRemoved() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = null; int mySecondTotalNrPersons = 0; int myExpectedNrOfPersons = 4; //Act myPeopleCollection = new People(); myPeopleCollection.AddPerson("Abel", "Jonsson"); myPeopleCollection.AddPerson("Ronja", "Axelsson"); myPeopleCollection.AddPerson("Gottfrid", "Larsson"); myPeopleCollection.AddPerson("Sahara", "Hotnight"); Person myPerson = new Person(0, "Per", "Banan"); // Delete this person myPeopleCollection.Remove(myPerson); mySecondTotalNrPersons = myPeopleCollection.Size(); //Assert Assert.Equal(myExpectedNrOfPersons, mySecondTotalNrPersons); }
public void FindUnassigned_FindOnlyOne_Arraysize3() { //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 4 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(null, description1); todoItems.AddToDoItem(null, description2); todoItems.AddToDoItem(null, description3); //act Todo[] foundItemsArray = todoItems.FindUnassignedTodoItems(); //assert Assert.Equal(3, foundItemsArray.Length); Assert.Equal(description1, foundItemsArray[0].Description); }
public void FindAllItems_FindsAll_CorrectArraySize() { //arrange int personId = PersonSequencer.nextPersonId(); string firstName = "Peter"; string familyName = "Jansson"; Person assignee = new Person(personId, firstName, familyName); int expectedSizeOfToDoItems = 3; string description1 = "Vattna blommor"; string description2 = "Dammsuga"; string description3 = "Putsa fönster"; TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 3 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(null, description3); //act Todo[] itemArray = todoItems.FindAll(); //assert Assert.Equal(expectedSizeOfToDoItems, itemArray.Length); }
public void DeleteObjectFromArrayTest() { People personList = new People(); personList.ClearPersons(); PersonSequencer.reset(); //Arrange string person_1_Firstname = "Per"; string person_1_Lastname = "Holknekt"; string person_2_Firstname = "Joey"; string person_2_Lastname = "Tribbiani"; string person_3_Firstname = "Mr"; string person_3_Lastname = "Bean"; PersonSequencer.reset(); People people = new People(); Person person_1 = people.NewPerson(person_1_Firstname, person_1_Lastname); Person person_2 = people.NewPerson(person_2_Firstname, person_2_Lastname); Person person_3 = people.NewPerson(person_3_Firstname, person_3_Lastname); Person[] result = { person_1, person_3, }; //Act people.RemoveObject(person_2); //Assert Assert.Equal(result, people.FindAll()); }
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 FindByDoneStatus_FindOnlyOne_Arraysize1() { //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"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); //set one item to done. Todo itemToBeDone = todoItems.FindById(1); itemToBeDone.Done = true; //act Todo[] foundItemsArray = todoItems.FindByDoneStatus(true); //assert Assert.Single(foundItemsArray); Assert.Equal(description1, foundItemsArray[0].Description); }
public void FindByDoneStatus_FindOnlyNotDone_Arraysize3() { //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 not done todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); todoItems.AddToDoItem(assignee, description3); //set one of the items to done. Todo itemToBeDone = todoItems.FindById(1); itemToBeDone.Done = true; //act Todo[] foundItemsArray = todoItems.FindByDoneStatus(false); //assert Assert.Equal(2, foundItemsArray.Length); }
public void FindItemById_FindOne_CorrectDescription() { //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"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); int size = todoItems.Size(); //act Todo foundLastItem = todoItems.FindById(size); Todo foundFirstItem = todoItems.FindById(1); //assert Assert.Equal(description2, foundLastItem.Description); Assert.Equal(description1, foundFirstItem.Description); }
public void FindItemById_UnknownId_NoneReturned() { //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"; TodoSequencer.reset(); TodoItems todoItems = new TodoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); int size = todoItems.Size(); //act Todo foundItem = todoItems.FindById(size + 3); //assert Assert.Null(foundItem); }
public void RemoveArrElement_TestThatAGivenObjectIsDeletedFromTheArray() { //Arrange string person_1_Firstname = "Neri"; string person_1_Lastname = "Chris"; string person_2_Firstname = "Joey"; string person_2_Lastname = "Ken"; string person_3_Firstname = "Akon"; string person_3_Lastname = "Akon"; PersonSequencer.reset(); 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); Person person_3 = people.CreatePerson(person_3_Firstname, person_3_Lastname); Person[] result = { person_1, person_3, }; //Act people.RemoveArrElement(person_2); //Assert Assert.Equal(result, people.FindAll()); }
public void FindItemById_UnknownId_NoneReturned() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); int size = todoItems.Size(); //act ToDo foundItem = todoItems.FindById(size + 3); //assert Assert.Null(foundItem); }
public void FindAllTest() { People personList = new People(); personList.ClearPersons(); PersonSequencer.reset(); personList.NewPerson("Pelle", "Plätt"); personList.NewPerson("Kenny", "Starfighter"); Person Ebbot = personList.NewPerson("Ebbot", "Lavén"); Person[] allPeople = personList.FindAll(); Assert.Equal(3, allPeople.Length); Assert.Equal("Pelle", allPeople[0].FirstName); Assert.Equal("Plätt", allPeople[0].LastName); Assert.Equal(1, allPeople[0].PersonID); Assert.Equal("Kenny", allPeople[1].FirstName); Assert.Equal("Starfighter", allPeople[1].LastName); Assert.Equal(2, allPeople[1].PersonID); Assert.Contains(Ebbot, allPeople); Assert.Equal("Lavén", allPeople[2].LastName); Assert.Equal(3, allPeople[2].PersonID); }
public void RunFindUnassignedTodoItems() { //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.FindUnassignedTodoItems(); //Assert Assert.NotEqual(newArray, actual); }
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 FindItemById_FindOne_CorrectDescription() { //arrange int personId = PersonSequencer.getNext(); string firstName = "Fredrik"; string familyName = "Persson"; Person assignee = new Person(personId, firstName, familyName); string description1 = "Walk the dog."; string description2 = "Cuddle with cat."; ToDoSequencer.Reset(); ToDoItems todoItems = new ToDoItems(); todoItems.Clear(); //add 2 items todoItems.AddToDoItem(assignee, description1); todoItems.AddToDoItem(assignee, description2); int size = todoItems.Size(); //act ToDo foundLastItem = todoItems.FindById(size); ToDo foundFirstItem = todoItems.FindById(1); //assert Assert.Equal(description2, foundLastItem.Description); Assert.Equal(description1, foundFirstItem.Description); }
public void Remove_AddPersonsRemoveOne_OnlyOneGone() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = null; int myFirstTotalNrPersons = 0; int mySecondTotalNrPersons = 0; int myExpectedNrOfPersons = 3; //Act myPeopleCollection = new People(); myPeopleCollection.AddPerson("Abel", "Jonsson"); myPeopleCollection.AddPerson("Ronja", "Axelsson"); Person myPerson = myPeopleCollection.AddPerson("Gottfrid", "Larsson"); // Delete this person myPeopleCollection.AddPerson("Sahara", "Hotnight"); myFirstTotalNrPersons = myPeopleCollection.Size(); myPeopleCollection.Remove(myPerson); mySecondTotalNrPersons = myPeopleCollection.Size(); //Assert Assert.NotEqual(myFirstTotalNrPersons, mySecondTotalNrPersons); Assert.Equal(myExpectedNrOfPersons, mySecondTotalNrPersons); }
public void NewIDIsOne() { PersonSequencer.reset(); //Arrange //TodoSeqencer Idcounter = new TodoSeqencer(); //Act int newid = PersonSequencer.nextPersonID(); Assert.Equal(1, newid); }
public void TestPersonSequencer() { //Arrange int expectedNesxpersonId = 1; Assert.Equal(expectedNesxpersonId, PersonSequencer.nextPersonId()); PersonSequencer.reset(); Assert.Equal(0, PersonSequencer.getPersonId()); //Assert }
public void ResetReset() { int newid = PersonSequencer.nextPersonID(); newid = PersonSequencer.nextPersonID(); PersonSequencer.reset(); PersonSequencer.reset(); newid = PersonSequencer.nextPersonID(); //Assert Assert.Equal(1, newid); }