Пример #1
0
        public void FindById_CreatePersonsLook4One_FoundOne()
        {
            //Arrange
            PersonSequencer.reset();
            People myPeopleCollection = new People();
            int    selectedPersonId   = 3;
            Person myLuckyPerson;

            myPeopleCollection.AddPerson("Abel", "Jonsson");
            myPeopleCollection.AddPerson("Kalle", "Jonson");
            myPeopleCollection.AddPerson("Nisse", "Johnsson");
            myPeopleCollection.AddPerson("Robert", "Jönsson");

            //Act
            myLuckyPerson = myPeopleCollection.FindById(selectedPersonId);

            //Assert
            Assert.Equal(selectedPersonId, myLuckyPerson.PersonId);
        }
Пример #2
0
        public void AddPerson_OnlyOnePersonAdd_DataInPersonRight()
        {
            //Arrange
            PersonSequencer.reset();
            People myPeopleCollection    = null;
            Person onePerson             = null;
            int    myFirstTotalNrPersons = 0;

            string myExpectedName = "Abel Jonsson";

            //Act
            myPeopleCollection = new People();
            onePerson          = myPeopleCollection.AddPerson("Abel", "Jonsson");

            myFirstTotalNrPersons = myPeopleCollection.Size();
            onePerson             = myPeopleCollection.FindById(myFirstTotalNrPersons);

            //Assert
            Assert.Equal(myExpectedName, onePerson.Name);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
0
        public void Remove_RemoveOneNotIncluded_NothingRemoved()
        {
            //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");
            Person myPerson = new Person(0, "Per", "Banan");    // Delete this person

            //Act
            myPeopleCollection.Remove(myPerson);
            mySecondTotalNrPersons = myPeopleCollection.Size();

            //Assert
            Assert.Equal(myExpectedNrOfPersons, mySecondTotalNrPersons);
        }
Пример #7
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);
        }