public void TestsIfFetchMethodReturnsTheElementsFromTheArray() { var db = new DataBaseClass(); db.Add(1); db.Add(2); db.Add(3); db.Add(4); db.Add(5); var expectedResult = new int[] { 1, 2, 3, 4, 5 }; var actualResult = db.Fetch(); Assert.AreEqual(expectedResult, actualResult, "Fetch method does not return all of the elements properly!"); }
public void ChecksIfAddMethodThrowsExceptionWhenOverloadsTheArray() { var db = new DataBaseClass(new int[] { 1, 2, 3, 4 }); Assert.Throws <InvalidOperationException>(() => db.Add(5)) .Message .Equals($"Can`t add more than {db.IntStorage.Length} elements!"); }
public void TestsIfAddMethodAddsAnElementToTheCorrectCell() { var db = new DataBaseClass(new int[5]); var type = typeof(DataBaseClass); db.Add(1); db.Add(2); db.Add(2); db.Add(2); var actualIndex = (int)type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .FirstOrDefault(x => x.Name == "currentIndex") .GetValue(db); int expectedIndex = 4; Assert.AreEqual(expectedIndex, actualIndex, "Add command does not set the number on the correct index"); }