예제 #1
0
        public void TestAddMethodValid(int value)
        {
            Database db = new Database();

            db.Add(value);

            FieldInfo valuesInfo = typeof(Database).GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                                   .First(fi => fi.FieldType == typeof(int[]));
            FieldInfo currentIndexInfo = typeof(Database).GetFields(BindingFlags.Instance | BindingFlags.NonPublic)
                                         .First(fi => fi.FieldType == typeof(int));

            int firstValue = ((int[])valuesInfo.GetValue(db)).First();

            Assert.That(firstValue, Is.EqualTo(value));

            int valuesCount = (int)currentIndexInfo.GetValue(db);

            Assert.That(valuesCount, Is.EqualTo(1));
        }
예제 #2
0
        public void AddOperationShouldAddElementAtNextFreeCell()
        {
            //Arrange
            int[]    numbers  = Enumerable.Range(1, 10).ToArray();
            Database database = new Database(numbers);

            //Act
            database.Add(5);
            var allElements = database.Fetch();

            //Assert
            var expectedResult = 5;
            var actualResult   = allElements[10];

            var expectedCount = 11;
            var actualCount   = database.Count;



            Assert.AreEqual(expectedResult, expectedResult);
            Assert.AreEqual(expectedCount, actualCount);
        }
예제 #3
0
 public void DatabaseMethodAddShouldThrowInvalidOperationExceptionIfTryToAdd17Element()
 {
     testDatabase = new Database(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 });
     Assert.Throws <InvalidOperationException>(() => testDatabase.Add(17));
 }
 public void Add()
 {
     database = new Database(1, 2);
     database.Add(3);
     Assert.That(database.Count == 3);
 }
 public void AddException()
 {
     Assert.Throws <InvalidOperationException>(() => database.Add(17));
 }
예제 #6
0
 public void AddMethodShouldThrowException()
 {
     int[] arry = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
     datebase = new Database(arry);
     Assert.Throws <InvalidOperationException>(() => datebase.Add(17));
 }
예제 #7
0
 public void TestedAddMethod()
 {
     Assert.That(() => dataBase.Add(1), Throws.InvalidOperationException);
 }
예제 #8
0
 public void TestIfInvalidOperationExeptionIsThrownWhenAddingMoreElementsThenCapacity()
 {
     Assert.That(() => database.Add(1), Throws.InvalidOperationException.With.Message.EqualTo("Array's capacity must be exactly 16 integers!"));
 }
예제 #9
0
 public void TestAddElementToDatabase()
 {
     emptyDatabase.Add(1);
     Assert.AreEqual(1, emptyDatabase.Count);
     Assert.AreEqual(1, emptyDatabase.Fetch()[0]);
 }
예제 #10
0
 public void Add_ShouldIncreaseDatabaseCount_WhenCapacityIsNotExceded()
 {
     emptydatabase.Add(1);
     emptydatabase.Add(2);
     Assert.AreEqual(2, emptydatabase.Count);
 }
예제 #11
0
 public void Add_ShouldThrowInvalidOperationException_WhenCapacityIsExceded()
 {
     Assert.Throws <InvalidOperationException>(() => database.Add(20));
 }
예제 #12
0
        public void MethodCantAddMoreThan16theenElements()
        {
            Database database = new Database(new int [16]);

            Assert.Throws <InvalidOperationException>(() => database.Add(10));
        }
예제 #13
0
        public void TestAddMethodShouldThrowAnExeption()
        {
            var database = new Database(firstItem, secondItem, thirdItem, fourthItem, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);

            Assert.Throws <InvalidOperationException>(() => database.Add(12));
        }
예제 #14
0
 public void AddShouldThrowWhenEndIsReached()
 {
     Assert.That(() => db.Add(17), Throws.InvalidOperationException);
 }
예제 #15
0
        public void CapacityShouldBe16Integers()
        {
            this.database = new Database(data);

            Assert.Throws <InvalidOperationException>(() => database.Add(1));
        }