public void RemoveMethodWorksCorrectly()
 {
     database.Add(new Person(123, "niki"));
     database.Add(new Person(1234, "gogo"));
     database.Remove();
     Assert.AreEqual(database.Count, 1);
 }
示例#2
0
        public void CantRemovePeopleIfEmpty()
        {
            Person[] pp = { pesho };
            var      db = new ExtendedDatabase(pp);

            db.Remove();
            Assert.Throws <InvalidOperationException>(() => db.Remove());
        }
示例#3
0
    public void TestRemovePeople()
    {
        extendedDatabase.Remove();

        var result = 0;

        Assert.AreEqual(extendedDatabase.Count, result);
    }
示例#4
0
        public void RemoveMethodShouldThrowException()
        {
            for (var i = database.Count - 1; i >= 0; i--)
            {
                database.Remove();
            }

            Assert.Throws <InvalidOperationException>(() => database.Remove());
        }
示例#5
0
        public void ValidifRemoveMethodDontWorkOnEmptyString(string message)
        {
            var database = new ExtendedDatabase(shortData);

            for (int i = 0; i < 5; i++)
            {
                database.Remove();
            }
            Assert.That(() => database.Remove(), Throws.InvalidOperationException, message);
        }
示例#6
0
        public void RemovePersonFromDatabase()
        {
            database.Add(kiro);
            database.Add(gosho);

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

            Assert.AreEqual(0, this.database.Count);
        }
        public void RemoveMethodShouldBeThrowInvalidOperationException()
        {
            Person person = new Person(1, "Pesho");

            ExtendedDatabase ext = new ExtendedDatabase(person);

            ext.Remove();

            Assert.Throws <InvalidOperationException>(() => ext.Remove());
        }
示例#8
0
        public void RemoveMethodShouldThrowInvalidOperationExceptionWhenArrayIs0()
        {
            Person[] people = new Person[1];

            people[0] = new Person(1, "Pesho1");
            var db = new ExtendedDatabase(people);

            db.Remove();
            Assert.Throws <InvalidOperationException>(() => db.Remove());
        }
示例#9
0
        public void DatabaseCannotRemoveWhenEmpty()
        {
            ExtendedDatabase testDb = new ExtendedDatabase(new List <Person> {
                new Person(0, "Stamat")
            });

            testDb.Remove();

            Assert.That(() => testDb.Remove(), Throws.InvalidOperationException);
        }
        public void RemoveShouldThrowExceptionWhenCountZero()
        {
            ExtendedDatabase data = new ExtendedDatabase(this.persons);

            data.Remove();
            data.Remove();
            Assert.Throws <InvalidOperationException>(() =>
            {
                data.Remove();
            });
        }
示例#11
0
    public void TestIfRemoveThrowsExceptionWhenCountIs0()
    {
        this.database = new ExtendedDatabase(people);

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

        Assert.Throws <InvalidOperationException>(() =>
        {
            database.Remove();
        });
    }
        public void Remove_Throws_InvalidOperationException_CountIs0(int count)
        {
            Person[] people = new Person[count];
            for (int i = 0; i < people.Length; i++)
            {
                people[i] = new Person(i, "Ivan" + i);
            }
            ExtendedDatabase extDb = new ExtendedDatabase(people);

            extDb.Remove();

            Assert.Throws <InvalidOperationException>
                (() => extDb.Remove());
        }
示例#13
0
        public void RemoveMethodShouldThrowInvalidOperationExceptionWhenCountIsZero()
        {
            Person[] persons =
            {
                new Person(1, "dizela")
            };

            ExtendedDatabase database = new ExtendedDatabase(persons);

            database.Remove();

            Assert.Throws <InvalidOperationException>(() =>
                                                      database.Remove());
        }
示例#14
0
        public void RemovingPersonsInTheArray()
        {
            int expectedCount = 0;

            database.Remove();
            Assert.That(database.Count, Is.EqualTo(expectedCount));
        }
示例#15
0
        public void TestValidRemove()
        {
            var values = new Person[]
            {
                new Person(1, "Pesho"),
                new Person(2, "Gosho")
            };

            var db = new ExtendedDatabase(values);

            var valuesLastElement = values[values.Length - 1];
            var removedElement    = db.Remove();

            var innerIndex = (int)typeof(ExtendedDatabase)
                             .GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                             .FirstOrDefault(f => f.FieldType == typeof(int))
                             .GetValue(db);
            var innerValues = (List <Person>) typeof(ExtendedDatabase)
                              .GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                              .FirstOrDefault(f => f.FieldType == typeof(List <Person>))
                              .GetValue(db);

            Assert.That(valuesLastElement, Is.EqualTo(removedElement));
            Assert.That(innerValues.Count, Is.EqualTo(values.Length - 1));
            Assert.That(innerIndex, Is.EqualTo(values.Length - 1));
        }
        public void PersonIsSuccesfullyRemovedFromDatabase()
        {
            ExtendedDatabase db = new ExtendedDatabase(new Person(1, "Tosho"), new Person(2, "Gancho"));

            db.Remove();
            Assert.That(db[1], Is.EqualTo(null));
        }
示例#17
0
        public void RemoveShouldThrowExceptionWhenCountZero()
        {
            Person[] persons = new Person[]
            {
                new Person(1234567890, "Pan1"),
                new Person(21234567890, "Pan2")
            };
            ExtendedDatabase extendedDatabase = new ExtendedDatabase(persons);

            extendedDatabase.Remove();
            extendedDatabase.Remove();
            Assert.Throws <InvalidOperationException>(() =>
            {
                extendedDatabase.Remove();
            });
        }
        public void RemoveEmptyCollectionShouldThrow()
        {
            var persons = new Person[] { };
            var db      = new ExtendedDatabase(persons);

            Assert.That(() => db.Remove(), Throws.InvalidOperationException);
        }
示例#19
0
        public void RemoveShouldDecreaseCount()
        {
            Person[] persons = new Person[]
            {
                new Person(1234567890, "Pan1"),
                new Person(21234567890, "Pan2"),
                new Person(31234567890, "Pan3"),
                new Person(41234567890, "Pan4"),
                new Person(51234567890, "Pan5"),
                new Person(61234567890, "Pan6"),
                new Person(71234567890, "Pan7"),
                new Person(81234567890, "Pan8"),
                new Person(91234567890, "Pan9"),
                new Person(101234567890, "Pan10"),
                new Person(111234567890, "Pan11"),
                new Person(121234567890, "Pan12"),
                new Person(131234567890, "Pan13"),
                new Person(141234567890, "Pan14"),
                new Person(151234567890, "Pan15"),
                new Person(161234567890, "Pan16")
            };

            ExtendedDatabase extendedDatabase = new ExtendedDatabase(persons);

            int expectedCount = 15;

            extendedDatabase.Remove();

            int actualCount = extendedDatabase.Count;

            Assert.That(actualCount, Is.EqualTo(expectedCount));
        }
示例#20
0
    public void TestIfCountDeacreaseAfterRemove()
    {
        var expected = 14;

        database.Remove();
        Assert.AreEqual(expected, database.Count);
    }
        public void Empty_Database_Should_Throw_Invalid_Operation_Exception_When_Using_Remove_Method()
        {
            // Arrange
            ExtendedDatabase database = new ExtendedDatabase();

            // Act - Assert
            Assert.Throws <InvalidOperationException>(() => database.Remove());
        }
        When_Person_Is_Being_Removed_From_An_Empty_Collection_Invalid_Operation_Exception_Should_Be_Thrown()
        {
            // Arrange
            ExtendedDatabase database = new ExtendedDatabase();

            // Act - Assert
            Assert.Throws <InvalidOperationException>(() => database.Remove());
        }
示例#23
0
        public void TestRemoveMethod()
        {
            var database = new ExtendedDatabase(firstPerson);

            database.Remove();

            Assert.AreEqual(database.Count, 0);
        }
        public void RemovingAnElementFromEmptyDBShouldThrowIOE()
        {
            //Arrange
            ExtendedDatabase db = new ExtendedDatabase();

            //Act && Assert
            Assert.Throws <InvalidOperationException>(() => db.Remove());
        }
        public void RemoveShouldRemove()
        {
            database.Remove();

            var expectedCount = 1;

            Assert.AreEqual(expectedCount, database.Count);
        }
        public void RemoveMethod()
        {
            edb = new ExtendedDatabase(new Person(123, "Gosho"));
            int expectedCount = edb.Count - 1;

            edb.Remove();
            Assert.AreEqual(expectedCount, edb.Count);
        }
        public void TestRemoveCorrectly()
        {
            testDatabase.Remove();

            int expectedCountOfPersons = 1;
            int actualCountOfPersons   = this.testDatabase.Count;

            Assert.AreEqual(expectedCountOfPersons, actualCountOfPersons);
        }
    public void FindByNameShouldThrowExceptionIfThereIsNoSuchPersonInTheRecord()
    {
        var db = new ExtendedDatabase();

        db.Add(ivan);
        db.Remove();

        Assert.Throws <InvalidOperationException>(() => db.FindByUsername("Ivan"));
    }
示例#29
0
        public void ShouldThrowExceptionWhenRemovingPersonFromEmptyCollection()
        {
            //Arrange
            var edb = new ExtendedDatabase();

            //Act - Assert
            Assert.Throws <InvalidOperationException>(()
                                                      => edb.Remove());
        }
示例#30
0
        public void Rmoving2PersonsShouldDecrementCountWith2()
        {
            //Arrange
            var edb = new ExtendedDatabase(new Person(1, "Az"));

            //Act
            edb.Add(new Person(2, "Ti"));
            edb.Add(new Person(3, "Toi"));

            edb.Remove();
            edb.Remove();

            var expectedValue = 1;
            var actualValue   = edb.Count;

            //Assert
            Assert.AreEqual(expectedValue, actualValue);
        }