public void NewPersonIsSuccesfullyAddedToDatabase()
        {
            ExtendedDatabase db = new ExtendedDatabase(new Person(2, "Joro"));

            db.Add(new Person(1, "Pesho"));
            Assert.IsTrue(personComparer.Equals(db[1], expectedPerson));
        }
Exemple #2
0
        public void FindByUserUnknowUserNameArgument()
        {
            var persons = new Person(1, "a");
            var db      = new ExtendedDatabase(persons);

            Assert.Throws <InvalidOperationException>(() => db.FindByUsername("b"));
        }
Exemple #3
0
        public void FindByUsernameShouldWorkCorrectly()
        {
            this.db = new ExtendedDatabase(new Person(1, "Pesho"));

            Assert.AreEqual("Pesho", this.db.FindByUsername("Pesho").UserName);
            Assert.AreEqual(1, this.db.FindByUsername("Pesho").Id);
        }
        public void FindByUserIdNegativeIdShouldThrowException()
        {
            ExtendedDatabase database = new ExtendedDatabase();


            Assert.Throws <ArgumentOutOfRangeException>(() => database.FindById(-1));
        }
Exemple #5
0
        public void FndByID_Check_ExceptionThrown_TryToFindWithNegativeIdParameter()
        {
            ExtendedDatabase database = new ExtendedDatabase();


            Assert.Throws <ArgumentOutOfRangeException>(() => database.FindById(-1));
        }
        public void FindByIdNonExistingPersonShouldThrow()
        {
            var persons = new Person[] { pesho, gosho };
            var db      = new ExtendedDatabase(persons);

            Assert.That(() => db.FindById(558877), Throws.InvalidOperationException);
        }
        public void RemoveEmptyCollectionShouldThrow()
        {
            var persons = new Person[] { };
            var db      = new ExtendedDatabase(persons);

            Assert.That(() => db.Remove(), Throws.InvalidOperationException);
        }
        public void Test_Add_Range_Exception_With_Empty_People()
        {
            Person[] people = new Person[17];

            Assert.Throws <ArgumentException>(() =>
                                              this.database = new ExtendedDatabase(people));
        }
        public void Test_Add_Null_People()
        {
            Person[] people = new Person[5];

            Assert.Throws <NullReferenceException>(() =>
                                                   this.database = new ExtendedDatabase(people));
        }
 public void TestIfConstructorIsInitializedWith16People()
 {
     //Arrange
     this.extendedDatabase = new /*ExtendedDatabase.*/ ExtendedDatabase(initialPeople);
     //Assert
     Assert.AreEqual(DatabaseCapacity, this.extendedDatabase.Count);
 }
 public void Setup()
 {
     this.person1  = new Person(100, "Pesho");
     this.person2  = new Person(101, "Gosho");
     this.person3  = new Person(102, "Shepo");
     this.database = new ExtendedDatabase(this.person1, this.person2);
 }
        public void ExceptionIsThrownWhenUsernameInputIsNullOrEmpty()
        {
            ExtendedDatabase db = new ExtendedDatabase(new Person(1, "Pesho"));

            Assert.Throws <ArgumentNullException>(() => db.FindByUsername(null), "Username cannot be null");
            Assert.Throws <ArgumentNullException>(() => db.FindByUsername(string.Empty), "Username cannot be null");
        }
        public void PersonIsSuccesfullyRemovedFromDatabase()
        {
            ExtendedDatabase db = new ExtendedDatabase(new Person(1, "Tosho"), new Person(2, "Gancho"));

            db.Remove();
            Assert.That(db[1], Is.EqualTo(null));
        }
        public void ExceptionIsThrownWhenNewPersonIsAddedToFullDatabase()
        {
            Person[]         input = Enumerable.Repeat(new Person(4, "Gosho"), 16).ToArray();
            ExtendedDatabase db    = new ExtendedDatabase(input);

            Assert.That(() => db.Add(new Person(6, "Stancho")), Throws.InvalidOperationException.With.Message.EqualTo("Database is full"));
        }
        public void FindByUsernameNullArgumentShouldThrow()
        {
            var persons = new Person[] { pesho, gosho };
            var db      = new ExtendedDatabase(persons);

            Assert.That(() => db.FindByUsername(null), Throws.ArgumentNullException);
        }
Exemple #16
0
        public void ValidIfThrowsExceptionWhenTryingToFindPersonWhoIsEmptyOrNull(string message)
        {
            var database = new ExtendedDatabase(shortData);

            Assert.That(() => database.FindByUsername(null), Throws.ArgumentNullException, message);
            Assert.That(() => database.FindByUsername(""), Throws.ArgumentNullException, message);
        }
        public void FindByUsernameIsCaseSensitive()
        {
            var persons = new Person[] { pesho, gosho };
            var db      = new ExtendedDatabase(persons);

            Assert.That(() => db.FindByUsername("GOSHO"), Throws.InvalidOperationException);
        }
Exemple #18
0
        public void AddMethodShouldIncreaseTheCountAndAddPersonCorrectly(string message)
        {
            var testDatabase = new ExtendedDatabase(shortData);

            testDatabase.Add(new Person(739319304, "Martincho"));
            Assert.AreEqual(6, testDatabase.Count, message);
        }
        public void FindByUsernameNegativeArgumentShouldThrow()
        {
            var persons = new Person[] { pesho, gosho };
            var db      = new ExtendedDatabase(persons);

            Assert.That(() => db.FindById(-5), Throws.Exception);
        }
Exemple #20
0
        public void FindByUserNameMethodShouldWorkCorrectly(string message)
        {
            var database     = new ExtendedDatabase(shortData);
            var actualPerson = database.FindByUsername("Arwen");

            Assert.AreEqual(shortData[0], actualPerson, message);
        }
    public void Numbers()
    {
        var persons = new Person[17];
        ExtendedDatabase db;

        Assert.Throws <ArgumentException>(() => db = new ExtendedDatabase(persons));
    }
Exemple #22
0
        public void FindByIdMethodShouldWorkCorrectly(string message)
        {
            var database     = new ExtendedDatabase(shortData);
            var targetPerson = database.FindById(12345678);

            Assert.AreEqual(shortData[0], targetPerson, message);
        }
        public void FindByIdEmptyCollectionShouldThrowException()
        {
            ExtendedDatabase database = new ExtendedDatabase();


            Assert.Throws <InvalidOperationException>(() => database.FindById(1));
        }
Exemple #24
0
        public void ValidIfInternalArrayLenghtIsSixteen(string message)
        {
            var database = new ExtendedDatabase(accurateData);
            int lenght   = database.Count;

            Assert.AreEqual(16, lenght, message);
        }
        public void IfNameIsNullOrEmpty_ShouldReturnException()
        {
            ExtendedDatabase dataBase = new ExtendedDatabase(new Person(3213, "Gosho"));

            Assert.Throws <ArgumentNullException>(() => dataBase.FindByUsername(null));
            Assert.Throws <ArgumentNullException>(() => dataBase.FindByUsername(string.Empty));
        }
Exemple #26
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 Setup()
 {
     this.person           = new Person(1213123132132332353, "username");
     this.extendedDatabase = new ExtendedDatabase();
     this.gosho            = new Person(123, "Gosho");
     this.pesho            = new Person(321, "Pesho");
 }
Exemple #28
0
        public void ConstructorShouldBeInitializedWithExatly16People()
        {
            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 extendedDatabase = new ExtendedDatabase(people);

            var actualCount   = extendedDatabase.Count;
            var expectedCount = 16;

            Assert.AreEqual(expectedCount, actualCount);
        }
Exemple #29
0
        public void FindByIdMethodThrowIfNumberOfIdIsNegative()
        {
            ExtendedDatabase database = new ExtendedDatabase();
            long             id       = -1;

            Assert.Throws <ArgumentOutOfRangeException>(() => database.FindById(id));
        }
Exemple #30
0
        public void CantAddPeopleWithTheSameId()
        {
            Person[] pp = { pesho, gosho };
            var      db = new ExtendedDatabase(pp);

            Assert.Throws <InvalidOperationException>(() => db.Add(new Person(123, "Pesdho")));
        }