Beispiel #1
0
        public void TestRemovingWorksCorrectly()
        {
            extendedDatabase.Remove();
            int expectedCount = 2;

            Assert.AreEqual(expectedCount, extendedDatabase.Count);
        }
        public void TestRemoveWorkCorrectly()
        {
            int expectedCount = 0;

            database.Remove();
            Assert.AreEqual(expectedCount, database.Count);
        }
Beispiel #3
0
 public void RemoveWhenDatabaseIsEmpty_Should_ThrowException()
 {
     Assert.Throws <InvalidOperationException>(() =>
     {
         database.Remove();
     });
 }
Beispiel #4
0
        public void RemoveMethodIsWorkTrue()
        {
            var expectedCount = 1;

            database.Remove();
            var actualCount = database.Count;

            Assert.AreEqual(expectedCount, actualCount);
        }
 public void RemovePersonFromEmptyDbShouldThrowException()
 {
     db = new ExtendedDatabase.ExtendedDatabase();
     while (db.Count > 0)
     {
         db.Remove();
     }
     Assert.That(() => db.Remove(), Throws.InvalidOperationException, "Remove a person from empty db.");
 }
Beispiel #6
0
        public void DatabaseShouldRemovePersonIfNotEmpty()
        {
            extendedDatabase.Remove();

            int expectedCount = 14;
            int result        = extendedDatabase.Count;

            Assert.AreEqual(expectedCount, result);
        }
        public void RemoveThrows_When_DatabaseIsEmpty()
        {
            Assert.That(() =>
            {
                database.Remove();
            }, Throws.InvalidOperationException);

            Assert.Throws <InvalidOperationException>(() => database.Remove());
        }
Beispiel #8
0
        public void RemoveMethod_Works()
        {
            var previousCount = database.Count;

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

            Assert.AreEqual(previousCount - 2, database.Count);
        }
Beispiel #9
0
        public void Test_Remove_From_Empty_Collection()
        {
            var currentPersons = persons.Take(1).ToArray();

            database = new ExtendedDatabase.ExtendedDatabase(currentPersons);
            database.Remove();

            Assert.Throws <InvalidOperationException>(() =>
            {
                database.Remove();
            });
        }
        public void RemoveMethodShouldThrowExceptionIfCountIs0()
        {
            this.people = new Person[1];
            for (int i = 0; i < people.Length; i++)
            {
                Person current = new Person(i + 213, $"username{i}");
                people[i] = current;
            }
            data = new ExtendedDatabase.ExtendedDatabase(people);
            data.Remove();



            Assert.Throws <InvalidOperationException>
                (() => data.Remove());
        }
Beispiel #11
0
    public void RemoveOperationShouldRemoveLastElement()
    {
        const long   lastPersonId       = 13579;
        const string lastPersonUsername = "******";
        const int    expectedCount      = 2;
        //Arrange
        List <Person> persons = new List <Person>()
        {
            new Person(12345, "Ivan"),
            new Person(67890, "Asen"),
            new Person(13579, "Gosho")
        };

        ExtendedDatabase.ExtendedDatabase database = new ExtendedDatabase.ExtendedDatabase(persons.ToArray());

        //Act
        database.Remove();

        //Assert
        int actualCount = database.Count;

        Assert.AreEqual(expectedCount, actualCount);
        Assert.Throws <InvalidOperationException>(() => database.FindById(lastPersonId));
        Assert.Throws <InvalidOperationException>(() => database.FindByUsername(lastPersonUsername));
    }
Beispiel #12
0
        public void RemoveCommand_DecreaseCount()
        {
            int expectedCount = database.Count - 1;

            database.Remove();
            Assert.AreEqual(database.Count, expectedCount);
        }
Beispiel #13
0
        public void RemoveEmptyCollectionShouldThrow()
        {
            var persons = new Person[] { };
            var db      = new ExtendedDatabase.ExtendedDatabase(persons);

            Assert.That(() => db.Remove(), Throws.InvalidOperationException);
        }
 public void RemoveThrowsExceptionIfNoPeople()
 {
     //Arrange
     database = new ExtendedDatabase.ExtendedDatabase();
     //Assert
     Assert.That(() => database.Remove(), //Act
                 Throws.InstanceOf <InvalidOperationException>());
 }
        public void RemovingFromEmptyDatabase_ShouldThrowException()
        {
            //Arrange
            var database = new ExtendedDatabase.ExtendedDatabase();

            //Act - Assert
            Assert.Throws <InvalidOperationException>(() => database.Remove());
        }
        public void CheckRemoveWorksCorrect()
        {
            extendedDatabase = new ExtendedDatabase(new Person(1, "A"));
            extendedDatabase.Remove();
            var expectedCount = 0;
            var realCount     = extendedDatabase.Count;

            Assert.AreEqual(expectedCount, realCount);
        }
Beispiel #17
0
        public void RemoveShouldThrowExceptionIfTryingToRemoveFromEmptyDatabase()
        {
            database = new ExtendedDatabase.ExtendedDatabase();

            Assert.Throws <InvalidOperationException>(() =>
            {
                database.Remove();
            });
        }
        public void CheckRemoveThrowExceptionIfCollectionIsEmpty()
        {
            extendedDatabase = new ExtendedDatabase();

            Assert.Throws <InvalidOperationException>(() =>
            {
                extendedDatabase.Remove();
            });
        }
Beispiel #19
0
        public void TestRemoveMethodWorksCorrectly()
        {
            int expectedCount = database.Count - 1;

            database.Remove();

            Assert.AreEqual(expectedCount, database.Count);
            Assert.AreEqual(null, database.Persons[expectedCount]);
        }
Beispiel #20
0
        public void RemoveMethodShouldReduceCountOfPeopleInDatabase()
        {
            Person gosho = new Person(1, "Gosho");
            Person pesho = new Person(2, "Pesho");

            database = new ExtendedDatabase.ExtendedDatabase(gosho, pesho);
            database.Remove();

            Assert.AreEqual(1, database.Count);
        }
Beispiel #21
0
        public void RemoveOperationShouldThrowExceptionIfCollectionIsEmpty()
        {
            // Arrange
            ExtendedDatabase.ExtendedDatabase database = new ExtendedDatabase.ExtendedDatabase();

            // Assert
            Assert.That(() => database.Remove(), Throws.InvalidOperationException);

            //Assert.Throws<InvalidOperationException>(() => database.Remove());
        }
        public void RemoveMethodShouldThrowExceptionIfYouTryToRemovePersonWhenCountIsZero()
        {
            // var person1 = new Person(0876757337, "Nikolay");
            // var people = new List<Person>();
            // people.Add(person1);
            var database = new ExtendedDatabase.ExtendedDatabase();

            // database.Remove();
            Assert.Throws <InvalidOperationException>(() => database.Remove());
        }
        public void RemovePersonFromDb()
        {
            Person person = new Person(1, "Pesho");

            db.Add(person);
            int expectedCount = db.Count - 1;

            db.Remove();
            Assert.That(db.Count, Is.EqualTo(expectedCount), "Didn't remove a person from db.");
        }
Beispiel #24
0
        public void RemoveOperationShouldRemovesPersonIfCollectionIsNotEmpty()
        {
            // Act
            database.Remove();

            int expectedCount = 1;
            int actualCount   = database.Count;

            // Assert
            Assert.AreEqual(expectedCount, actualCount);
        }
        public void RemoveWorksCorrectly()
        {
            //Arrange
            database.Remove();
            //Act
            var expectedCount = people.Count() - 1;
            var actualCount   = database.Count;

            //Assert
            Assert.That(expectedCount, Is.EqualTo(actualCount));
        }
        public void Remove_DecreaseDatabaseCount()
        {
            int personToAdd = 5;

            LoopPersonToAdd(personToAdd);
            // int countBeforeRemove = extendedDatabase.Count;  no need it

            extended.Remove();

            Assert.That(extended.Count, Is.EqualTo(personToAdd - 1), "After one time remove count should be countBeforeRemove -1");
        }
Beispiel #27
0
        public void RemoveShouldRemove()
        {
            var persons = new Person[] { pesho, gosho };
            var db      = new ExtendedDatabase.ExtendedDatabase(persons);

            db.Remove();

            var expectedCount = 1;

            Assert.AreEqual(expectedCount, db.Count);
        }
Beispiel #28
0
        public void RemoveWorksProperly()
        {
            CreatePeople(16);

            ExtendedDatabase.ExtendedDatabase extendedDatabase = new ExtendedDatabase.ExtendedDatabase(people);

            int expecretCount = 15;

            extendedDatabase.Remove();

            Assert.AreEqual(expecretCount, extendedDatabase.Count);
        }
Beispiel #29
0
        public void RemoveFromDatabaseMustDecreaseCount()
        {
            Person[] people = new Person[]
            {
                new Person(1, "Test1"),
                new Person(2, "Test2"),
                new Person(3, "Test3"),
            };

            extendedDatabase = new ExtendedDatabase.ExtendedDatabase(people);
            extendedDatabase.Remove();
            Assert.AreEqual(extendedDatabase.Count, 2);
        }
Beispiel #30
0
        public void RemoveFromDatabaseMustRemovePerson()
        {
            Person[] people = new Person[]
            {
                new Person(1, "Test1"),
                new Person(2, "Test2"),
                new Person(3, "Test3"),
            };

            extendedDatabase = new ExtendedDatabase.ExtendedDatabase(people);
            extendedDatabase.Remove();
            Assert.Catch <InvalidOperationException>(() => extendedDatabase.FindById(3));
        }