public void FindByUsername_ThrowError_InputIsNull(int id)
    {
        ExtendDatabase db = new ExtendDatabase(new Person(1, "Ivcho_55"), new Person(2, "Ivcho_1255"));

        Assert.That(() => db.FindById(id),
                    Throws.Exception);
    }
    public void AddMethodTest_ThrowsExeption_ToManyElements(Person person)
    {
        Person[] people = new Person[16] {
            new Person(1, "Ivcho_55"),
            new Person(2, "Nasko_123"),
            new Person(3, "Asi_123"),
            new Person(4, "Toni_123"),
            new Person(5, "VanioHaha"),
            new Person(6, "GafyKucheto"),
            new Person(7, "NasoKila"),
            new Person(8, "GennadyGolovkin"),
            new Person(9, "CaneloAlvares"),
            new Person(10, "FloydMayweather"),
            new Person(11, "ConnotMcgregor"),
            new Person(12, "DanaWhite"),
            new Person(13, "Joshua"),
            new Person(14, "Mamba"),
            new Person(15, "KocetoManiqka"),
            new Person(16, "IoanEKomarjiq")
        };

        ExtendDatabase db = new ExtendDatabase(people);

        Assert.That(() => db.Add(person),
                    Throws.InvalidOperationException
                    .With.Message.EqualTo("Storage is full!"));
    }
    public void FindByUsername_ThrowError_InputIsNull(string username)
    {
        ExtendDatabase db = new ExtendDatabase(new Person(1, "Ivcho_55"), new Person(2, "Ivcho_1255"));

        Assert.That(() => db.FindByUsername(username),
                    Throws.ArgumentNullException);
    }
    public void AddMethodTest(Person person)
    {
        ExtendDatabase db = new ExtendDatabase();

        db.Add(person);
        Assert.That(db.Fetch(), Is.EqualTo(new Person[] { person }));
    }
    public void TestConstructor_NoArray()
    {
        ExtendDatabase db = new ExtendDatabase(new Person(1, "Ivcho_55"), new Person(2, "Nasko_123"));

        Person[] result = db.Fetch();

        Assert.That(result.FirstOrDefault().Username, Is.EqualTo("Ivcho_55"));
    }
Exemplo n.º 6
0
        public void RemovePersonFromEmptyDB()
        {
            //Act
            ExtendDatabase db = new ExtendDatabase();

            // Assert
            Assert.Throws <InvalidOperationException>(() => db.Remove());
        }
    public void TestConstructor()
    {
        Person[] people = new Person[2] {
            new Person(1, "Ivcho_55"), new Person(2, "Nasko_123")
        };
        ExtendDatabase db = new ExtendDatabase(people);

        Assert.That(db.Fetch(), Is.EqualTo(people));
    }
    public void FindById_ThrowExeption_UserNotFound(int id)
    {
        ExtendDatabase db = new ExtendDatabase(new Person(1, "IvoIvo"), new Person(2, "Kondio"), new Person(3, "KrasoTapaka"));

        Assert.That(() => db.FindById(id),
                    Throws.InvalidOperationException
                    .With
                    .Message
                    .EqualTo($"User with Id {id} don't exists!"));
    }
    public void FindByUsername_ThrowExeption_UserNotFound(string username)
    {
        ExtendDatabase db = new ExtendDatabase(new Person(1, "IvoIvo"), new Person(2, "Kondio"), new Person(3, "KrasoTapaka"));

        Assert.That(() => db.FindByUsername(username),
                    Throws.InvalidOperationException
                    .With
                    .Message
                    .EqualTo($"User with Username {username} don't exists!"));
    }
Exemplo n.º 10
0
    public void AddMethodTest_IdExists_Exeption(Person person)
    {
        ExtendDatabase db = new ExtendDatabase(new Person(17, "Gaby"), new Person(7, "Nasko"), new Person(11, "Toni"));

        Assert.That(() => db.Add(person),
                    Throws
                    .InvalidOperationException
                    .With
                    .Message
                    .EqualTo("Id already exists!"));
    }
Exemplo n.º 11
0
    public void RemoveTest()
    {
        Person[] people = new Person[1] {
            new Person(1, "Ivcho_55")
        };

        ExtendDatabase db = new ExtendDatabase(people);

        db.Remove();

        Assert.That(db.Fetch(), Is.EqualTo(new Person[] { }));
    }
Exemplo n.º 12
0
    public void RemoveTest_ThrowError_EmptyArray()
    {
        Person[] people = new Person[1] {
            new Person(1, "Ivcho_55")
        };

        ExtendDatabase db = new ExtendDatabase(people);

        db.Remove();

        Assert.That(() => db.Remove(), Throws.InvalidOperationException.With.Message.EqualTo("Storage is Empty!"));
    }
Exemplo n.º 13
0
    public void FetchMethodTest()
    {
        ExtendDatabase db = new ExtendDatabase(new Person(1, "Ivcho_55"), new Person(2, "Ivcho_1255"), new Person(3, "Ivcho_55325"));

        db.Add(new Person(4, "IvanchoGolemeca"));
        db.Remove();
        db.Remove();
        db.Remove();
        db.Remove();

        Assert.That(db.Fetch(), Is.EquivalentTo(new Person[] { }));
    }
Exemplo n.º 14
0
        public void FindByIDNegativeInDB(long firstId, string firstUsername, long secondId, string secondUsername, long negativeId)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });

            // Assert
            Assert.Throws <ArgumentOutOfRangeException>(() => db.FindById(negativeId));
        }
Exemplo n.º 15
0
        public void DatabaseInitializeConstructorWithCollectionOfPeople(long firstId, string firstUsername, long secondId, string secondUsername)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });

            // Assert
            Assert.AreEqual(2, db.Count, $"Constructor doesn't work with {typeof(Person)} as parameter");
        }
Exemplo n.º 16
0
        public void FindByUserName_NullIDInDB_ThrowException(long firstId, string firstUsername, long secondId, string secondUsername)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });

            // Assert
            Assert.Throws <ArgumentNullException>(() => db.FindByUsername(null), $"Searched null in database");
        }
Exemplo n.º 17
0
        public void FindByUserName_Casesensitive_ThrowException(long firstId, string firstUsername, long secondId, string secondUsername, string searchedUserName)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });

            // Assert
            Assert.Throws <InvalidOperationException>(() => db.FindByUsername(searchedUserName), $"Find by UserName isn't case sensitive!");
        }
Exemplo n.º 18
0
        public void FindByIDNonExistingPersonInDB(long firstId, string firstUsername, long secondId, string secondUsername, long nonexistingId)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });

            // Assert
            Assert.Throws <InvalidOperationException>(() => db.FindById(nonexistingId));
        }
Exemplo n.º 19
0
        public void FindByIDExistingPersonInDB(long firstId, string firstUsername, long secondId, string secondUsername)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });
            var searchedById = db.FindById(firstId);

            // Assert
            Assert.AreEqual(firstPerson, searchedById, $"Search {typeof(Person)} by Id doesn't work");
        }
Exemplo n.º 20
0
        public void AddPersonWithSameUserNameThrowException(long firstId, string firstUsername, long secondId, string secondUsername, long thirdId, string thirdUsername)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);
            var thirdPerson  = new Person(thirdId, thirdUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });

            // Assert
            Assert.Throws <InvalidOperationException>(() => db.Add(thirdPerson), $"Additing person with same username doesn't throw an exception message");
        }
Exemplo n.º 21
0
        public void FindByUserName_PersonNotInDB_ThrowException(long firstId, string firstUsername, long secondId, string secondUsername, long thirdId, string thirdUsername)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);
            var thirdPerson  = new Person(thirdId, thirdUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });

            // Assert
            Assert.Throws <InvalidOperationException>(() => db.FindByUsername(thirdUsername), $"Searched person doesn't exist in database");
        }
Exemplo n.º 22
0
        public void FindByUserName(long firstId, string firstUsername, long secondId, string secondUsername, long thirdId, string thirdUsername)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);
            var thirdPerson  = new Person(thirdId, thirdUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson, thirdPerson
            });

            // Assert
            Assert.AreEqual(thirdPerson, db.FindByUsername(thirdUsername), "Find by userName do not work !");
        }
Exemplo n.º 23
0
        public void RemoveLastPersonFromDB(long firstId, string firstUsername, long secondId, string secondUsername)
        {
            // Arrange
            var firstPerson  = new Person(firstId, firstUsername);
            var secondPerson = new Person(secondId, secondUsername);

            // Act
            ExtendDatabase db = new ExtendDatabase(new List <Person>()
            {
                firstPerson, secondPerson
            });

            db.Remove();

            // Assert
            Assert.AreEqual(firstPerson, db.Elements[0], $"Remove {typeof(Person)} doesn't work");
        }
Exemplo n.º 24
0
    public void FindById(int id)
    {
        ExtendDatabase db = new ExtendDatabase(new Person(1, "Ivcho_55"), new Person(2, "Ivcho_1255"), new Person(3, "Ivcho_55325"));

        Assert.That(db.FindById(id).Id, Is.EqualTo(id));
    }
Exemplo n.º 25
0
    public void TestConstructor_NoParameters()
    {
        ExtendDatabase db = new ExtendDatabase();

        Assert.That(db.Fetch(), Is.EqualTo(new Person[] { }));
    }
Exemplo n.º 26
0
 public void Initialization()
 {
     this.database = new ExtendDatabase();
 }
Exemplo n.º 27
0
    public void FindByUsername(string username)
    {
        ExtendDatabase db = new ExtendDatabase(new Person(1, "Ivcho_55"), new Person(2, "Ivcho_1255"), new Person(3, "Ivcho_55325"));

        Assert.That(db.FindByUsername(username).Username, Is.EquivalentTo(username));
    }