Ejemplo n.º 1
0
    public void TestAddPerson()
    {
        extendedDatabase.Add(new Person(123456, "Vasil"));
        var resul = 2;

        Assert.AreEqual(extendedDatabase.Count, resul);
    }
Ejemplo n.º 2
0
        public void TesAddShouldNotAddExistingUsername()
        {
            this.testDatabase.Add(testPerson);
            Person newPerson = new Person(1111, testUsername);

            Assert.That(() => testDatabase.Add(newPerson), Throws.InvalidOperationException);
        }
    public void AddingPersonWithTheSameNameShouldThrowException()
    {
        var db = new ExtendedDatabase();

        db.Add(ivan);

        Assert.Throws <InvalidOperationException>(() => db.Add(new Person(1, "Ivan")));
    }
        public void AddMethodAddExistingPersonIDShouldThrowException()
        {
            ExtendedDatabase database = new ExtendedDatabase();

            database.Add(new Person(1, "A"));

            Assert.Throws <InvalidOperationException>(() => database.Add(new Person(1, "B")));
        }
        public void AddMethodIfPersonAlreadyExist()
        {
            Person person  = new Person(123121, "Gosho");
            Person person2 = new Person(1212, "Gosho");

            edb.Add(person);
            Assert.That(() => edb.Add(person2), Throws.InvalidOperationException);
        }
        public void Add_SameId_ShouldThrowException()
        {
            ExtendedDatabase db = new ExtendedDatabase();

            db.Add(new Person(1, "a"));

            Assert.Throws <InvalidOperationException>(() => db.Add(new Person(1, "b")));
        }
        public void TestThatTrowExceptionIfUserAlredyExist()
        {
            var username = "******";

            extendedDatabase.Add(new Person(23, username));

            Assert.Throws <InvalidOperationException>(() => extendedDatabase.Add(new Person(3, username)));
        }
Ejemplo n.º 8
0
    public void TestIfExceptionIsThrownWhenUsernameAlreadyExists()
    {
        var duplicateUsername = new Person(12, "Bobby");

        Assert.Throws <InvalidOperationException>(() =>
        {
            database.Add(duplicateUsername);
        });
    }
    public void AddShouldIncrementTheCountProperly()
    {
        var db = new ExtendedDatabase();

        db.Add(ivan);
        db.Add(gosho);
        var expectedCount = 2;

        Assert.AreEqual(expectedCount, db.Count);
    }
Ejemplo n.º 10
0
        public void TestShouldAddPerson()
        {
            var newPerson = new Person(123456789, "Stamat");

            database.Add(newPerson);

            int expectedCount = 3;

            Assert.AreEqual(expectedCount, database.Count);
        }
Ejemplo n.º 11
0
        public void RemovePersonFromDatabase()
        {
            database.Add(kiro);
            database.Add(gosho);

            database.Remove();
            database.Remove();

            Assert.AreEqual(0, this.database.Count);
        }
Ejemplo n.º 12
0
        public void FindByUsername_ShouldReturnPersonIfFound()
        {
            database.Add(testPerson);
            Person person = database.FindByUsername(testPerson.UserName);

            Assert.AreSame(testPerson, person);
        }
        public void Add_MoreThan16Elements_ShouldThrowException()
        {
            ExtendedDatabase db = new ExtendedDatabase();

            for (int i = 0; i < 16; i++)
            {
                db.Add(new Person(i, i.ToString()));
            }

            Assert.Throws <InvalidOperationException>(() => db.Add(new Person(16, "16")));
        }
Ejemplo n.º 14
0
        public void TestShouldThrowExeptionWhenAddSameId()
        {
            ExtendedDatabase data = new ExtendedDatabase();

            data.Add(new Person(1, "A"));

            Assert.Throws <InvalidOperationException>(() =>
            {
                data.Add(new Person(1, "B"));
            });
        }
    public void RemoveShouldDecreaseTheCountOfTheDatabase()
    {
        var db = new ExtendedDatabase();

        db.Add(ivan);
        db.Add(gosho);
        db.Remove();
        var expectedCount = 1;

        Assert.AreEqual(expectedCount, db.Count);
    }
Ejemplo n.º 16
0
        public void AddExistingUserIdShouldThrowException()
        {
            ExtendedDatabase db = new ExtendedDatabase();

            Person person  = new Person(1, "Vanko1");
            Person person2 = new Person(1, "Vanko5");

            db.Add(person);

            Assert.That(() => db.Add(person2), Throws.InvalidOperationException.With.Message.EqualTo("User with this id already exists!"));
        }
Ejemplo n.º 17
0
        public void TestAddInFullDatabase()
        {
            Person[] people = CreatePeople(15);

            ExtendedDatabase newDatabase = new ExtendedDatabase(people);

            newDatabase.Add(personOne);


            Assert.Throws <InvalidOperationException>(() => newDatabase.Add(personTwo));
        }
        public void FindById_NoUserWithId_ThrowsException()
        {
            ExtendedDatabase db = new ExtendedDatabase();

            db.Add(new Person(1, "a"));
            db.Add(new Person(2, "b"));
            db.Add(new Person(3, "c"));
            db.Add(new Person(4, "d"));

            Assert.Throws <InvalidOperationException>(() => db.FindById(11));
        }
Ejemplo n.º 19
0
        public void AddOver16UsersReturnInvalidOperationException()
        {
            var persons = new Person[16];
            var db      = new ExtendedDatabase();

            for (int i = 0; i < persons.Length; i++)
            {
                db.Add(new Person(i + 1, $"a{i}"));
            }

            Assert.That(() => db.Add(new Person(18, "z")), Throws.InvalidOperationException);
        }
Ejemplo n.º 20
0
    public void Add_AddItemWithUsernameAlreadyPresent_ThrowsInvalidOperationExecption()
    {
        var initialIdPerson1      = 1;
        var initialIdPerson2      = 2;
        var initialUsernamePerson = "Genadi";
        var db      = new ExtendedDatabase();
        var person1 = new Person(initialIdPerson1, initialUsernamePerson);
        var person2 = new Person(initialIdPerson2, initialUsernamePerson);

        db.Add(person1);
        Assert.That(() => db.Add(person2), Throws.InvalidOperationException);
    }
Ejemplo n.º 21
0
 public void When_CtroInvolveAndCapacityExceeded_ShouldThrowException()
 {
     Person[] people = new Person[MaxCapicty + 1];
     for (int i = 0; i < MaxCapicty; i++)
     {
         database.Add(new Person(i, $"Username{i}"));
     }
     Assert.Throws <ArgumentException>(() => new ExtendedDatabase(people));
 }
Ejemplo n.º 22
0
        public void DatabaseAddsElementAsLastElement()
        {
            int    userId   = 66;
            string userName = "******";

            Person user = new Person(userId, userName);

            db.Add(user);

            Person lastElement = db.GetLastElement();

            Assert.That(user, Is.EqualTo(lastElement));
            System.Console.WriteLine();
        }
Ejemplo n.º 23
0
    public void FindByUsername_FindNull_ThrowsNullArgumentException()
    {
        var id1   = 1;
        var id2   = 2;
        var name1 = "Genadi";
        var name2 = "Stavri";
        var db    = new ExtendedDatabase();
        var p1    = new Person(id1, name1);
        var p2    = new Person(id2, name2);

        db.Add(p1);
        db.Add(p2);
        Assert.Throws <ArgumentNullException>(() => db.FindByUsername(null));
    }
Ejemplo n.º 24
0
        public void AddingTwoPersonsShouldIncrementCounterWith2()
        {
            //Arrange
            var edb = new ExtendedDatabase(new Person(3, "Pif"));

            //Act
            edb.Add(new Person(4, "Vanya"));
            edb.Add(new Person(5, "Cveti"));
            var expectedValue = 3;
            var actualValue   = edb.Count;

            //Assert
            Assert.AreEqual(expectedValue, actualValue);
        }
Ejemplo n.º 25
0
        public void IfTehereAreUsersWithThisIDThrowException()
        {
            //Arrange
            Person Person = new Person(5, "Anatoli");

            ExtendedDatabase extendedDatabase = new ExtendedDatabase();

            extendedDatabase.Add(Person);

            //Act-Assert

            Assert.Throws <InvalidOperationException>(()
                                                      => extendedDatabase.Add(Person));
        }
Ejemplo n.º 26
0
        public void AddingPersonsInTheArray()
        {
            string name = "Pesho";
            long   id   = 1;

            Person person = new Person(id, name);

            database.Add(person);

            Assert.That(database.Count, Is.EqualTo(2));
        }
    public void Adding_Two_Persons_Should_Increment_Count_With_Two()
    {
        // Arrange
        var db = new ExtendedDatabase(new Person(48, "Alfonso"));

        // Act
        db.Add(new Person(3, "Simba"));
        db.Add(new Person(1, "Gergana"));

        var actualResult   = db.Count;
        var expectedResult = 3;

        // Assert
        Assert.That(actualResult, Is.EqualTo(expectedResult));
    }
        public void FindById_WorksCorrectly()
        {
            ExtendedDatabase db = new ExtendedDatabase();

            Person expectedResult = new Person(1, "a");

            db.Add(new Person(2, "b"));
            db.Add(new Person(3, "c"));
            db.Add(expectedResult);
            db.Add(new Person(4, "d"));

            Person actualResult = db.FindById(expectedResult.Id);

            Assert.That(actualResult, Is.EqualTo(expectedResult));
        }
Ejemplo n.º 29
0
        public void AddMethodShouldThrowInvalidOperationExceptionIfWeTryToAdd17Person()
        {
            Person[] people = new Person[16];
            people[0]  = new Person(1, "Pesho1");
            people[1]  = new Person(12, "Pesho2");
            people[2]  = new Person(123, "Pesho3");
            people[3]  = new Person(1234, "Pesho4");
            people[4]  = new Person(12345, "Pesho5");
            people[5]  = new Person(123456, "Pesho6");
            people[6]  = new Person(1234567, "Pesho7");
            people[7]  = new Person(12345678, "Pesho8");
            people[8]  = new Person(123456789, "Pesho9");
            people[9]  = new Person(12345678910, "Pesho10");
            people[10] = new Person(1234567891011, "Pesho11");
            people[11] = new Person(123456789101112, "Pesho12");
            people[12] = new Person(12345678910111213, "Pesho13");
            people[13] = new Person(1234567891011121314, "Pesho14");
            people[14] = new Person(1234567891011121315, "Pesho15");
            people[15] = new Person(1234567891011121316, "Pesho16");

            var db = new ExtendedDatabase(people);

            var additionalPerson = new Person(23123132, "Shano");

            Assert.Throws <InvalidOperationException>(() => db.Add(additionalPerson));
        }
        public void AddMethodAddPersonShouldAddCorectly()
        {
            ExtendedDatabase database    = new ExtendedDatabase();
            Person           personOne   = new Person(1, "A");
            Person           personTwo   = new Person(2, "B");
            Person           personThree = new Person(3, "C");

            database.Add(personOne);
            database.Add(personTwo);
            database.Add(personThree);

            Person actualPerson = database.FindById(2);

            Assert.AreEqual(2, actualPerson.Id);
            Assert.AreEqual("B", actualPerson.UserName);
        }