public void Person_CreateValidPerson_NamesOk() { int myPersonID = 0; string myFirstName = "Bosse"; string myLastName = "Larsson"; string myNameResult = "Bosse Larsson"; PersonSequencer.Reset(); Person myPerson = new Person(myPersonID, myFirstName, myLastName); // Assert Assert.Equal(myNameResult, myPerson.Name); }
public void NextPersonId_StepupId_Increase() { //Arrange int expectedId = 1; PersonSequencer.Reset(); //Act int getId = PersonSequencer.getNext(); // Assert Assert.Equal(expectedId, getId); }
public void FindById_CreateArrayButEmpty_ReturnNull() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = new People(); int selectedPersonId = 3000; Person myLuckyPerson; //Act myLuckyPerson = myPeopleCollection.FindById(selectedPersonId); //Assert Assert.Null(myLuckyPerson); }
[Fact] //Test if it resets to 0 public void TestResetSequence() { //Arrange PersonSequencer.NextPersonId(); int personIdReset = 1; //Act PersonSequencer.Reset(); int resetId = PersonSequencer.NextPersonId(); //Assert Assert.Equal(personIdReset, resetId); }
public void RunReset() { //Run reset before act to remove possible static values PersonSequencer.Reset(); //Arrange & //Act int firstId = PersonSequencer.NextPersonId(); PersonSequencer.Reset(); int secondId = PersonSequencer.NextPersonId(); //Assert Assert.Equal(1, secondId); }
public void PeopleFindAllTest() { // Arrange PersonSequencer.Reset(); People people = new People(); people.NewPerson("Lars", "Lilja"); people.NewPerson("Jens", "Vik"); // Act Person[] actual = people.FindAll(); // Assert Assert.True(actual.Length == 2); }
public void FindAll_NoneAdded_ReturnEmptyArray() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = new People(); int expectedSizeOfPeople = 0; //Act int myLengthOfPeople = myPeopleCollection.Size(); Person[] foundPersons = myPeopleCollection.FindAll(); //Assert Assert.Equal(expectedSizeOfPeople, myLengthOfPeople); Assert.Empty(foundPersons); }
public void FindSizeTest() { //Arrange People people = new People(); PersonSequencer.Reset(); int size = 1; int personId = 1; people.AddNewPerson(personId, "Donald", "Duck"); //Act int result = people.Size(); //Assert Assert.Equal(size, result); }
public void PersonResetTest() { // Arrange int expected = 1; PersonSequencer.nextPersonId(); int num = PersonSequencer.nextPersonId(); //tests reset Method PersonSequencer.Reset(); int actual = PersonSequencer.nextPersonId(); // Assert Assert.Equal(expected, actual); Assert.True(num >= 2);//Assert control number }
public void PeopleClearTest() { // Arrange int expected = 0; People people = new People(); PersonSequencer.Reset(); people.NewPerson("Lasse", "Nääf");// creates persons to be removed people.NewPerson("Nils", "Korv"); // Act people.Clear(); int actual = people.Size(); // Assert Assert.Equal(actual, expected); }
public void PeopleSizeTest() { // Arrange PersonSequencer.Reset(); int expected = 2; People people = new People(); people.NewPerson("Lars", "Lilja");// creates people to fill array people.NewPerson("Jens", "Vik"); // Act int actual = people.Size(); // Assert Assert.Equal(expected, actual); }
public void FindByIDTest() //Test to find if it finds the ID { //Arrange People people = new People(); int personId = 1; PersonSequencer.Reset(); people.AddNewPerson(personId, "Donald", "Duck"); //Act Person result = people.FindById(personId); //Assert Assert.Contains("Donald", result.PersonInformation()); Assert.Contains("Duck", result.PersonInformation()); Assert.Contains(personId.ToString(), result.PersonInformation()); }
public void ResetToZero() { //arrange int expected = 1; // To be sure there tested numbers stored in personId variabal for (int i = 0; i < 10; i++) { PersonSequencer.NextPersonId(); } //act PersonSequencer.Reset(); int result = PersonSequencer.NextPersonId(); //Assert to be sure the reset acts to reset the personId Assert.Equal(expected, result); }
public void FindByIDTest() //Test to find if it finds the ID { //Arrange ToDoItems toDoItems = new ToDoItems(); int toDoId = 1; string description = "Learn to code"; PersonSequencer.Reset(); toDoItems.AddNewToDo(toDoId, description); //Act ToDo result = toDoItems.FindToDoById(toDoId); //Assert Assert.Contains(toDoId.ToString(), result.ToDoInformation()); Assert.Contains(description, result.ToDoInformation()); }
public void FindSizeTest() { //Arrange ToDoItems toDoItems = new ToDoItems(); int size = 1; int toDoId = 1; PersonSequencer.Reset(); string toDo = "Learn to code"; toDoItems.AddNewToDo(toDoId, toDo); //Act int result = toDoItems.Size(); //Assert Assert.Equal(size, result); }
public void PersonSequencerTest() { // Arrange int expected = 1; int expected2 = 2; // Act PersonSequencer.Reset();// resets sequencer to always get expected results int actual = PersonSequencer.nextPersonId(); int actual2 = PersonSequencer.nextPersonId(); // Assert // Asserts nextPersonId Assert.Equal(expected, actual); Assert.Equal(expected2, actual2); }
public void RunNextPersonId() { PersonSequencer.Reset(); //Arrange int firstId = 1; int secondId = 2; //Act int firstResult = PersonSequencer.NextPersonId(); int secondResult = PersonSequencer.NextPersonId(); //Assert Assert.Equal(firstId, firstResult); Assert.Equal(secondId, secondResult); PersonSequencer.Reset(); }
public void PersonIdCountUpResets() { //Arrange int expected = 1; for (int i = 0; i < 10; i++) { PersonSequencer.NextPersonId(); } //Act PersonSequencer.Reset(); int result = PersonSequencer.NextPersonId(); //Assert Assert.Equal(expected, result); }
public void AddNewPersonToArrayTest() { //Arrange People people = new People(); string firstname = "Jane"; string lastname = "Doe"; int newPersonID = 1; //Act people.Clear(); PersonSequencer.Reset(); Person result = people.AddNewPerson(newPersonID, firstname, lastname); //Assert Assert.NotNull(result); Assert.Contains(firstname, result.PersonInformation()); Assert.Contains(lastname, result.PersonInformation()); Assert.Contains(newPersonID.ToString(), result.PersonInformation()); }
public void FindById_CreatePersonsLook4OneNotThere_FoundNoone() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = new People(); int selectedPersonId = 3000; Person myLuckyPerson; //Act myPeopleCollection.AddPerson("Abel", "Jonsson"); myPeopleCollection.AddPerson("Kalle", "Jonson"); myPeopleCollection.AddPerson("Nisse", "Johnsson"); myPeopleCollection.AddPerson("Robert", "Jönsson"); myLuckyPerson = myPeopleCollection.FindById(selectedPersonId); //Assert Assert.Null(myLuckyPerson); }
public void NewPersonTest() { // Arrange People people = new People(); string firstName = "lasse"; string lastName = "björk"; int expectedId = 1; PersonSequencer.Reset(); // Act Person result = people.NewPerson(firstName, lastName); // Assert Assert.NotNull(result);// checks that method actually worked Assert.Contains(firstName, result.PersonInformation()); Assert.Contains(lastName, result.PersonInformation()); Assert.Contains(expectedId.ToString(), result.PersonInformation()); }
public void AddPerson_OnlyOnPersonAdd_DataInPersonRight() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = null; Person onePerson = null; int myPersonId = 0; int myFirstTotalNrPersons = 0; string myExpectedName = "Abel Jonsson"; //Act myPeopleCollection = new People(); onePerson = myPeopleCollection.AddPerson("Abel", "Jonsson"); myPersonId = onePerson.PersonId; myFirstTotalNrPersons = myPeopleCollection.Size(); onePerson = myPeopleCollection.FindById(myPersonId); //Assert Assert.Equal(myExpectedName, onePerson.Name); }
public void AddPerson_OnlyOnePersonAdd_OnlyOnePersonIn() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = null; int myFirstTotalNrPersons = 0; Person onePerson = null; int mySecondTotalNrPersons = 0; int myExpectedNumberOfPersons = 1; //Act myPeopleCollection = new People(); myFirstTotalNrPersons = myPeopleCollection.Size(); onePerson = myPeopleCollection.AddPerson("Abel", "Jonsson"); mySecondTotalNrPersons = myPeopleCollection.Size(); //Assert Assert.NotEqual(myFirstTotalNrPersons, mySecondTotalNrPersons); Assert.Equal(myExpectedNumberOfPersons, mySecondTotalNrPersons); }
public void FindAll_Added4_ReturnAll() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = new People(); int expectedNrOfPersons = 4; myPeopleCollection.AddPerson("Abel", "Jonsson"); myPeopleCollection.AddPerson("Kalle", "Jonson"); myPeopleCollection.AddPerson("Nisse", "Johnsson"); myPeopleCollection.AddPerson("Robert", "Jönsson"); //Act int myNrOfPeople = myPeopleCollection.Size(); Person[] foundPersons = myPeopleCollection.FindAll(); //Assert Assert.Equal(expectedNrOfPersons, myNrOfPeople); Assert.Equal(expectedNrOfPersons, foundPersons.Length); }
public void FindByDoneStatusTest() { // People people = new People(); ToDoItems toDo = new ToDoItems(); PersonSequencer.Reset(); TodoSequencer.ResetID(); Person Jane = people.AddNewPerson(1, "Jane", "Doe"); ToDo item1 = toDo.AddNewToDoNew(1, "Win lotto", false, Jane); ToDo item2 = toDo.AddNewToDoNew(1, "Learn to code", true, Jane); //Act ToDo[] result = toDo.FindByDoneStatus(); //Assert Assert.Contains(item2, result); //Jane has learned to code Assert.DoesNotContain(item1, result); //Jane has not yet won the lotto }
public void Remove_RemoveNull_NothingRemovedNoCrash() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = null; int mySecondTotalNrPersons = 0; int myExpectedNrOfPersons = 4; myPeopleCollection = new People(); myPeopleCollection.AddPerson("Abel", "Jonsson"); myPeopleCollection.AddPerson("Ronja", "Axelsson"); myPeopleCollection.AddPerson("Gottfrid", "Larsson"); myPeopleCollection.AddPerson("Sahara", "Hotnight"); //Act myPeopleCollection.Remove(null); mySecondTotalNrPersons = myPeopleCollection.Size(); //Assert Assert.Equal(myExpectedNrOfPersons, mySecondTotalNrPersons); }
public void RunPersonRemove() { //Arange People people = new People(); PersonSequencer.Reset(); people.Clear(); Person firstPerson = people.NewPerson("Anders", "Karlsson"); Person secondPerson = people.NewPerson("Bengt", "Andersson"); Person thirdPerson = people.NewPerson("Arne", "Berglund"); Person[] newArray = new Person[0]; //Act Person[] actual = people.Remove(2); //Assert Assert.NotEqual(newArray, actual); }
public void Clear_AddPersonsClear_AllGone() { //Arrange PersonSequencer.Reset(); People myPeopleCollection = null; int myFirstTotalNrPersons = 0; int mySecondTotalNrPersons = 0; int myExpectedNrOfPersons = 0; //Act myPeopleCollection = new People(); myPeopleCollection.AddPerson("Abel", "Jonsson"); myPeopleCollection.AddPerson("Ronja", "Axelsson"); myPeopleCollection.AddPerson("Gottfrid", "Larsson"); myFirstTotalNrPersons = myPeopleCollection.Size(); myPeopleCollection.Clear(); mySecondTotalNrPersons = myPeopleCollection.Size(); //Assert Assert.NotEqual(myFirstTotalNrPersons, mySecondTotalNrPersons); Assert.Equal(myExpectedNrOfPersons, mySecondTotalNrPersons); }
public void RemovePersonObjectTest() { //Arrange People people = new People(); PersonSequencer.Reset(); int result = 1; int personToRemove = 2; Person Jane = people.AddNewPerson(1, "Jane", "Doe"); Person John = people.AddNewPerson(2, "John", "Doe"); //Act people.RemovePersonObject(personToRemove); int size = people.Size(); Person[] remaining = people.FindAll(); //Assert Assert.Equal(result, size); Assert.Contains(Jane, remaining); Assert.DoesNotContain(John, remaining); }
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); }