예제 #1
0
        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);
        }
예제 #2
0
        public void NextPersonId_StepupId_Increase()
        {
            //Arrange
            int expectedId = 1;

            PersonSequencer.Reset();

            //Act
            int getId = PersonSequencer.getNext();

            // Assert
            Assert.Equal(expectedId, getId);
        }
예제 #3
0
        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);
        }
예제 #4
0
        [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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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());
        }
예제 #13
0
        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);
        }
예제 #14
0
        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());
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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();
        }
예제 #18
0
        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);
        }
예제 #19
0
        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());
        }
예제 #20
0
        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);
        }
예제 #21
0
        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());
        }
예제 #22
0
        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);
        }
예제 #23
0
        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);
        }
예제 #24
0
        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);
        }
예제 #25
0
        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
        }
예제 #26
0
        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);
        }
예제 #27
0
        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);
        }
예제 #28
0
        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);
        }
예제 #29
0
        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);
        }
예제 #30
0
        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);
        }