Example #1
0
        public void AddUserMethod_AddsPerson(string name)
        {
            var person = new Person(212112, name);

            database.Add(person);
            Assert.That(database.Count == 3);
        }
Example #2
0
        public void AddCommand_ThrowsException_WhenUserIDExists()
        {
            database = new ExtendedDatabase.ExtendedDatabase();
            database.Add(new Person(1, "Username"));

            Assert.Throws <InvalidOperationException>(() => database.Add(new Person(1, "Username2")));
        }
Example #3
0
        public void AddPersonAddPersonCorectly()
        {
            person = new Person(id, name);
            emptyExtendedDatabase.Add(person);

            Assert.AreEqual(person, emptyExtendedDatabase.FindById(id));
        }
Example #4
0
        public void AddingExistingPersonNameShouldThrowEx()
        {
            Person person  = new Person(17, "Gary");
            Person person2 = new Person(18, "Gary");

            this.emptyDatabase.Add(person);
            Assert.Throws <InvalidOperationException>(() => emptyDatabase.Add(person2));
        }
Example #5
0
        public void TestThatAddingWorksCorrectly()
        {
            var person = new Person(4, "Johny");

            extendedDatabase.Add(person);
            int expectedPeopleCount = 4;

            Assert.AreEqual(expectedPeopleCount, extendedDatabase.Count);
        }
        public void AddMethodThrowsAnExceptionWhenCapacityIsExceeded()
        {
            for (int i = 0; i < 16; i++)
            {
                data.Add(new Person(i, $"{i}"));
            }

            Assert.Throws <InvalidOperationException>(() => data.Add(new Person(100, "Ivo")));
        }
        public void TestAddPeoppleWorkCorrectly()
        {
            int expectedCount = 2;

            var person = new Person(3, "Tisho");

            database.Add(person);

            Assert.AreEqual(expectedCount, database.Count);
        }
Example #8
0
        public void AddOperationShouldAddPersonIfCollectionIsNotFull()
        {
            // Act
            database.Add(new Person(789, "thirdPerson"));

            int expectedCount = 3;
            int actualCount   = database.Count;

            // Assert
            Assert.AreEqual(expectedCount, actualCount);
        }
Example #9
0
        public void TestAddUserExceptionCount()
        {
            for (int i = 0; i < 14; i++)
            {
                database.Add(new Person(i, $"Name_ + {100 + i}"));
            }

            Assert.That(() => database.Add(new Person(51446, "Ivane")),
                        Throws.InvalidOperationException.With.Message.EqualTo("Array's capacity must be exactly 16 integers!"));
            //Assert.Throws<InvalidOperationException>(() => this.database = new ExtendedDatabase.ExtendedDatabase(person));
        }
 public void AddThrowsExceptionIfCountIs16()
 {
     //Arrange
     for (int i = 0; i < 12; i++)
     {
         database.Add(new Person(i + 5, i.ToString()));
     }
     //Assert
     Assert.That(() => database.Add(null), //Act
                 Throws.InstanceOf <InvalidOperationException>());
 }
Example #11
0
        public void DatabaseShouldThrowExceptionWhenCountIsAbove16()
        {
            Person person17 = new Person(17, "Bobi17");



            extendedDatabase.Add(new Person(16, "Bobi16"));



            Assert.Throws <InvalidOperationException>(() => extendedDatabase.Add(person17));
        }
        public void AddingUserWithExistingIdInTheDatabase_ShouldThrowException()
        {
            //Arrange
            var database = new ExtendedDatabase.ExtendedDatabase();
            var userOne  = new Person(2, "usernameOne");
            var userTwo  = new Person(2, "usernameTwo");

            //Act
            database.Add(userOne);

            //Assert
            Assert.Throws <InvalidOperationException>(() => database.Add(userTwo));
        }
Example #13
0
 public void AddMethodThrowException()
 {
     persons = new Person[15];
     for (int i = 1; i < persons.Length; i++)
     {
         persons[i] = new Person(i + 1, $"{i+1}nqkywSITam");
         database.Add(persons[i]);
     }
     Assert.That(() =>
     {
         database.Add(new Person(1, "Wert"));
     }, Throws.InvalidOperationException);
 }
        public void FindByUserName_With_ExistentName()
        {
            Person person = new Person(1, "Duman");

            // Person personTwo = new Person(2, "Duman2"); Just to check test
            extended.Add(person);
            Person findedPerson = extended.FindByUsername(person.UserName);

            Assert.IsNotNull(findedPerson);
            Assert.That(findedPerson, Is.EqualTo(person));

            //throw new InvalidOperationException("No user is present by this username!")
        }
 public void AddThrows_When_CapacityIsExceeded()
 {
     Assert.That(() =>
     {
         for (int i = 0; i < 17; i++)
         {
             database.Add(new ExtendedDatabase.Person(i, $"{i}"));
         }
     }, Throws.InvalidOperationException.With.Message.EqualTo("Array's capacity must be exactly 16 integers!"));
 }
        public void AddValidPersonToDb()
        {
            int    expectedCount = db.Count + 1;
            Person person        = new Person(1, "Pesho");

            db.Add(person);
            Assert.That(db.Count, Is.EqualTo(expectedCount), "Didn't add a person to db.");
        }
Example #17
0
        public void AddOperationShouldThrowExceptionIfCollectionIsFull()
        {
            // Arrange
            ExtendedDatabase.ExtendedDatabase database = new ExtendedDatabase.ExtendedDatabase();

            for (int i = 0; i < 16; i++)
            {
                database.Add(new Person(i, $"Test {i}"));
            }

            // Assert
            Assert.That(
                () => database.Add(new Person(17, "Test 17")), // Act
                Throws.InvalidOperationException.With.Message.EqualTo("Array's capacity must be exactly 16 integers!"));
        }
 public void AddValidPersonToFullDbShouldThrowException()
 {
     #region
     Person p1  = new Person(1, "a1");
     Person p2  = new Person(2, "a2");
     Person p3  = new Person(3, "a3");
     Person p4  = new Person(4, "a4");
     Person p5  = new Person(5, "a5");
     Person p6  = new Person(6, "a6");
     Person p7  = new Person(7, "a7");
     Person p8  = new Person(8, "a8");
     Person p9  = new Person(9, "a9");
     Person p10 = new Person(10, "a10");
     Person p11 = new Person(11, "a11");
     Person p12 = new Person(12, "a12");
     Person p13 = new Person(13, "a13");
     Person p14 = new Person(14, "a14");
     Person p15 = new Person(15, "a15");
     Person p16 = new Person(16, "a16");
     db = new ExtendedDatabase.ExtendedDatabase(new Person[16] {
         p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16
     });
     #endregion
     Assert.That(() => db.Add(new Person(14213, "yett")), Throws.InvalidOperationException, "Added person to full db.");
 }
Example #19
0
        public void AddRangeShouldThrowExceptionWhenDatabaseIsFull()
        {
            Person[] data = new Person[] {
                new Person(1, "a"),
                new Person(2, "b"),
                new Person(3, "c"),
                new Person(4, "d"),
                new Person(5, "e"),
                new Person(6, "f"),
                new Person(7, "g"),
                new Person(8, "h"),
                new Person(9, "i"),
                new Person(10, "j"),
                new Person(11, "k"),
                new Person(12, "l"),
                new Person(13, "m"),
                new Person(14, "n"),
                new Person(15, "o"),
                new Person(16, "p"),
            };
            var newDatabase = new ExtendedDatabase.ExtendedDatabase(data);

            //Assert
            Assert.That(() => newDatabase.Add(this.person),
                        Throws.InvalidOperationException.With.Message
                        .EqualTo("Array's capacity must be exactly 16 integers!"));
        }
        public void AddingUser_WhenNotEnoughSpace_ShouldThrowException()
        {
            //Arrange
            var database = new ExtendedDatabase.ExtendedDatabase();
            var testUser = new Person(99, "test");

            //Act
            for (int person = 0; person < 16; person++)
            {
                var user = new Person(person, $"username-{person}");
                database.Add(user);
            }

            //Assert
            Assert.Throws <InvalidOperationException>(() => database.Add(testUser));
        }
        public void CheckAddMethodThrowExceptionIfCapacityIsFull()
        {
            var persons = new Person[]
            {
                new Person(01, "X"),
                new Person(02, "A"),
                new Person(03, "B"),
                new Person(04, "C"),
                new Person(05, "D"),
                new Person(06, "E"),
                new Person(07, "F"),
                new Person(08, "G"),
                new Person(09, "H"),
                new Person(10, "I"),
                new Person(11, "J"),
                new Person(12, "K"),
                new Person(13, "L"),
                new Person(14, "M"),
                new Person(15, "N"),
                new Person(16, "O"),
            };

            extendedDatabase = new ExtendedDatabase(persons);
            var persom = new Person(1, "Z");

            Assert.Throws <InvalidOperationException>(() =>
            {
                extendedDatabase.Add(person);
            });
        }
Example #22
0
        public void Add_ThrowException_WhenCapacityIsExceeded()
        {
            long   id     = 16;
            string name   = "Invalid Username";
            var    person = new Person(id, name);

            for (int i = 0; i < 16; i++)
            {
                database.Add(new Person(i, $"Username: {i}"));
            }

            Assert.Throws <InvalidOperationException>(() => database.Add(person));
        }
Example #23
0
        public void AddSameIdShouldThrow()
        {
            var persons   = new Person[] { pesho, gosho };
            var db        = new ExtendedDatabase.ExtendedDatabase(persons);
            var newPerson = new Person(11223344, "Stamat");

            Assert.That(() => db.Add(newPerson), Throws.InvalidOperationException);
        }
        public void Add_Should_Throw_Invalid_Operation_Exception_If_Array_Is_More_Than_16_Elements(
            long personId,
            string personUsername)
        {
            //Arrange
            for (int i = 0; i < 16; i++)
            {
                person = new Person(1000000000000L + i, "Ivan" + i);
                extendedDatabase.Add(person);
            }

            //Act
            Person anotherPerson = new Person(personId, personUsername);

            //Assert
            Assert.Throws <InvalidOperationException>(() => extendedDatabase.Add(anotherPerson));
        }
        public void ShouldAddUserCorrectly()
        {
            Person person1 = new Person(200, "Tosho");
            Person person2 = new Person(300, "Gosho");

            ExtendedDatabase.ExtendedDatabase database = new ExtendedDatabase.ExtendedDatabase(person1);
            database.Add(person2);
            Assert.That(database.Count == 2);
        }
        public void Add_ThrowsException_WhenCountExceedsCapacity()
        {
            for (int i = 0; i < 16; i++)
            {
                this.extendedDatabase.Add(new Person(i, $"Username {i}"));
            }

            Assert.Throws <InvalidOperationException>(() => extendedDatabase.Add(new Person(16, "Invalid Username")));
        }
Example #27
0
        public void FindById_ReturnsExpectedPersonById()
        {
            Person person = new Person(15, "Kristian");

            database.Add(person);

            Person dbPerson = database.FindById(person.Id);

            Assert.That(person, Is.EqualTo(dbPerson));
        }
Example #28
0
        public void AddThrowsExceptionWhenAddedMoreThan16People(int count, int id, string name)
        {
            CreatePeople(count);

            ExtendedDatabase.ExtendedDatabase extendedDatabase = new ExtendedDatabase.ExtendedDatabase(people);

            Person person = new Person(id, name);

            Assert.Throws <InvalidOperationException>(() => extendedDatabase.Add(person));
        }
Example #29
0
        public void Test_Add_Person_Works_Correctly()
        {
            var currentPersons = persons.Take(2).ToArray();

            database = new ExtendedDatabase.ExtendedDatabase(currentPersons);

            person = new Person(1234656890, "Pesho");
            database.Add(person);

            Assert.AreEqual(3, database.Count);
        }
Example #30
0
        public void TestShouldAddPerson()
        {
            var persons   = new Person[] { pesho, gosho };
            var db        = new ExtendedDatabase.ExtendedDatabase(persons);
            var newPerson = new Person(123456789, "Stamat");

            db.Add(newPerson);

            int expectedCount = 3;

            Assert.AreEqual(expectedCount, db.Count);
        }