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)); }
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); }
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)); }
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)); }
public void TestedAddMethod() { Assert.That(() => dataBase.Add(1), Throws.InvalidOperationException); }
public void TestIfInvalidOperationExeptionIsThrownWhenAddingMoreElementsThenCapacity() { Assert.That(() => database.Add(1), Throws.InvalidOperationException.With.Message.EqualTo("Array's capacity must be exactly 16 integers!")); }
public void TestAddElementToDatabase() { emptyDatabase.Add(1); Assert.AreEqual(1, emptyDatabase.Count); Assert.AreEqual(1, emptyDatabase.Fetch()[0]); }
public void Add_ShouldIncreaseDatabaseCount_WhenCapacityIsNotExceded() { emptydatabase.Add(1); emptydatabase.Add(2); Assert.AreEqual(2, emptydatabase.Count); }
public void Add_ShouldThrowInvalidOperationException_WhenCapacityIsExceded() { Assert.Throws <InvalidOperationException>(() => database.Add(20)); }
public void MethodCantAddMoreThan16theenElements() { Database database = new Database(new int [16]); Assert.Throws <InvalidOperationException>(() => database.Add(10)); }
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)); }
public void AddShouldThrowWhenEndIsReached() { Assert.That(() => db.Add(17), Throws.InvalidOperationException); }
public void CapacityShouldBe16Integers() { this.database = new Database(data); Assert.Throws <InvalidOperationException>(() => database.Add(1)); }