Exemplo n.º 1
0
        public void DatabaseCapacityIsSixteen()
        {
            IntDataBase db = new IntDataBase(new List <int>()
            {
                1, 2
            });

            Assert.AreEqual(16, db.Capacity, "Capacity must be 16");
        }
Exemplo n.º 2
0
        public void DatebaseElementsReturnsValidCollection()
        {
            //Arrange
            IntDataBase db = new IntDataBase(new List <int>()
            {
                1, 2, 3
            });

            //Assert
            CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, db.Elements);
            Assert.AreEqual(3, db.Count, string.Format(ErrorMessageForDifferentCount, 3));
        }
Exemplo n.º 3
0
        public void DatabaseAddElement()
        {
            //Arrange
            IntDataBase db = new IntDataBase(new List <int>()
            {
                1
            });

            //Act
            db.Add(2);

            //Assert
            Assert.AreEqual(2, db.Count, ErrorMessageForDifferentCount, 2);
        }
Exemplo n.º 4
0
        public void RemoveSingleElement()
        {
            //Arrange
            IntDataBase db = new IntDataBase(new List <int>()
            {
                1, 2, 3, 4
            });

            //Act
            db.Remove();

            //Assert
            CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, db.Elements);
        }
Exemplo n.º 5
0
        public void CheckIfAddedElementsIsLastElementInCollection()
        {
            //Arrange
            IntDataBase db = new IntDataBase(new List <int>()
            {
                1
            });

            //Act
            db.Add(2);

            //Assert
            CollectionAssert.AreEqual(new int[] { 1, 2 }, db.Elements);
        }
Exemplo n.º 6
0
        public void DatabaseAddMoreElementsThanCapacityOfDatabase(int count)
        {
            //Arrange
            List <int> list = new List <int>();

            for (int i = 0; i < count; i++)
            {
                list.Add(i);
            }
            IntDataBase db = new IntDataBase(list);

            //Assert
            Assert.Throws <InvalidOperationException>(() => db.Add(3), "Cannot add more elements than max capacity");
        }
Exemplo n.º 7
0
        public void RemoveMoreElementsThanCollectionHave()
        {
            //Arrange
            IntDataBase db = new IntDataBase(new List <int>()
            {
                1, 2
            });

            //Act
            db.Remove();
            db.Remove();

            //Assert
            Assert.Throws <InvalidOperationException>(() => db.Remove());
        }
Exemplo n.º 8
0
        public void DatebaseContructorWorkWithValidNumberOfElements(int count)
        {
            //Arrange
            List <int> list = new List <int>();

            for (int i = 0; i < count; i++)
            {
                list.Add(i);
            }

            //Act
            IntDataBase db = new IntDataBase(list);

            //Assert
            Assert.AreEqual(count, db.Count, string.Format(ErrorMessageForDifferentCount, count));
        }