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 AddMethodTest(Person person)
    {
        ExtendDatabase db = new ExtendDatabase();

        db.Add(person);
        Assert.That(db.Fetch(), Is.EqualTo(new Person[] { person }));
    }
    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!"));
    }
    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[] { }));
    }
Esempio n. 5
0
        public void AddPersonWhenDBIsFull()
        {
            // Act
            for (int i = 0; i < this.database.Capacity; i++)
            {
                this.database.Add(new Person(1 + i, $"{i}1"));
            }

            // Assert

            Assert.Throws <InvalidOperationException>(
                () => database.Add(new Person(this.database.Capacity, $"{this.database.Capacity}1")));
        }
Esempio n. 6
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");
        }