Exemple #1
0
 public void ListShouldSearchesForGivenElement()
 {
     intDynamicList = new DynamicList <int>();
     intDynamicList.Add(100);
     intDynamicList.Add(200);
     Assert.AreEqual(1, intDynamicList.IndexOf(200), "List cannot search at specified index");
 }
Exemple #2
0
        public void Add_OneReferenceTypeElementAdded_ShouldBeEqual()
        {
            string checkValue = "Pesho";

            dynamicStringList.Add(checkValue);
            Assert.AreEqual("Pesho", dynamicStringList[0], "The value of \"Pesho\" string should be equal as the value of the first element of the dynamic list");
        }
Exemple #3
0
 public void TestInitialize()
 {
     list = new DynamicList <int>();
     list.Add(5);
     list.Add(10);
     list.Add(2500);
 }
Exemple #4
0
        public void Add_NullElementInExistingList_ShouldThrowExcepion()
        {
            var stringList = new DynamicList <string>();

            stringList.Add("Pesho");
            stringList.Add(null);
        }
 public void TestIndexOf()
 {
     list = new DynamicList <int>();
     list.Add(1);
     list.Add(2);
     Assert.AreEqual(list.IndexOf(1), 0);
 }
 public void TestContainsMethod()
 {
     list = new DynamicList <int>();
     list.Add(2);
     list.Add(3);
     Assert.AreEqual(list.Contains(3), true);
 }
Exemple #7
0
        public void IndexOperatorShouldReturnValue()
        {
            list.Add(FirstElementInList);
            int element = list[0];

            Assert.That(element, Is.EqualTo(FirstElementInList));
        }
Exemple #8
0
        public void AddMethodShouldAddNullWhenArgumentIsNull()
        {
            myList.Add(null);
            var lastPosition = myList.Count - 1;

            Assert.AreEqual(null, myList[lastPosition]);
        }
Exemple #9
0
 public void Count_GetCountOnNonEmptyDynamicList_ShouldReturnExpectedCount()
 {
     dynamicList.Add(24);
     dynamicList.Add(-3);
     dynamicList.Add(4);
     Assert.AreEqual(3, dynamicList.Count);
 }
Exemple #10
0
        public void Contains_OnNonExistingElement_ShouldReturnFalse()
        {
            dynamicList.Add(1);
            var contains = dynamicList.Contains(2);

            Assert.IsFalse(contains);
        }
Exemple #11
0
 public void This_GetElementGreaterThanDynamicListLength_ShouldThorwArgumentOutOfRangeException()
 {
     dynamicList.Add(5);
     dynamicList.Add(2);
     dynamicList.Add(3);
     var emptyList = dynamicList[4];
 }
        static void Main(string[] args)
        {
            var dl = new DynamicList(new HtmlListRenderStrategy());

            dl.Add("foo");
            dl.Add("bar");
            dl.Add("baz");

            WriteLine(dl);
            dl.ChangeRenderStrategy(new MarkdownListRenderStrategy());
            WriteLine(dl);

            var htmlList = new StaticList <HtmlListRenderStrategy>();

            htmlList.Add("item 1");
            htmlList.Add("item 2");
            htmlList.Add("item 3");
            WriteLine(htmlList);

            var mdList = new StaticList <MarkdownListRenderStrategy>();

            mdList.Add("item 1");
            mdList.Add("item 2");
            mdList.Add("item 3");
            WriteLine(mdList);
        }
Exemple #13
0
        public void IndexOfPass(int value)
        {
            DynamicList <int> dynamicList = new DynamicList <int>();

            dynamicList.Add(20);
            dynamicList.Add(10);
            Assert.AreEqual(1, dynamicList.Remove(value));
        }
Exemple #14
0
 public void Test_IndexGetReturnsThirdElementOneHundread()
 {
     var dynList = new DynamicList<int>();
     dynList.Add(10);
     dynList.Add(50);
     dynList.Add(100);
     Assert.AreEqual(100, dynList[2], "Index do not returns the correct value of an element at specified index.");
 }
Exemple #15
0
 public void ChangeValueOfGivenPositionShoudChangeTheValueAtThisPosition()
 {
     var numList = new DynamicList<int>();
     numList.Add(2);
     numList.Add(-10);
     numList[0] = 9;
     Assert.AreEqual(numList[0], 9, "The value is not equal to the expected change.");
 }
Exemple #16
0
        public void ContainsNotPass(int value)
        {
            DynamicList <int> dynamicList = new DynamicList <int>();

            dynamicList.Add(20);
            dynamicList.Add(10);
            Assert.AreEqual(false, dynamicList.Contains(value));
        }
        public void Test_RemoveAtOnIndexGreaterThanCount_ShouldTrowArgumentOutOfRangeException()
        {
            var list = new DynamicList <int>();

            list.Add(0);
            list.Add(1);
            list.RemoveAt(2);
        }
 public void GetElementWithIncorrectIndexShoudThrowArgumentNullException()
 {
     var list = new DynamicList<int>();
     
     list.Add(2);
     list.Add(6);
     int element = list[2];
 }
Exemple #19
0
        public void RemoveAtArgumentOutOfRangeException(int value)
        {
            DynamicList <int> dynamicList = new DynamicList <int>();

            dynamicList.Add(10);
            dynamicList.Add(20);
            Assert.Throws <ArgumentOutOfRangeException>(() => dynamicList.RemoveAt(4));
        }
Exemple #20
0
        public void SetUp()
        {
            numbers = new DynamicList <int>();

            numbers.Add(1);
            numbers.Add(2);
            numbers.Add(3);
        }
Exemple #21
0
 public void AddingMoreElementsShouldIncreaseTheElemetsCount()
 {
     var numList = new DynamicList<int>();
     numList.Add(2);
     numList.Add(-10);
     numList.Add(5);
     Assert.AreEqual(3, numList.Count, "The list count is not equal to the number of added elements.");
 }
        public void TestRemoveMethod_WithNonExistingObject_ShouldReturnNegativeValue()
        {
            DynamicList<int> arr = new DynamicList<int>();
            arr.Add(1);
            arr.Add(2);

            Assert.AreEqual(-1, arr.Remove(3), "The Remove method shuld not remove non-existing objects!");
        }
Exemple #23
0
 public void FoundingElementInListShouldReturnIndexOfElement()
 {
     var numList = new DynamicList<int>();
     numList.Add(13);
     numList.Add(-6);
     int index = numList.IndexOf(-6);
     Assert.AreEqual(1, index, "Invalid index.");
 }
 public void TestCountCommand()
 {
     list = new DynamicList <int>();
     list.Add(1);
     list.Add(2);
     list.Add(3);
     Assert.AreEqual(list.Count, 3);
 }
 public void TestRemoveAtCommand()
 {
     list = new DynamicList <int>();
     list.Add(1);
     list.Add(2);
     list.Add(3);
     Assert.AreEqual(list.RemoveAt(0), 1);
 }
Exemple #26
0
        public void SetUp()
        {
            names = new DynamicList <string>();

            names.Add("Pepi");
            names.Add("Micheto");
            names.Add("Evlogi");
        }
 public void TestCountAfterAddTwoElementsToList()
 {
     DynamicList<int> list = new DynamicList<int>();
     list.Add(1);
     list.Add(2);
     int count = list.Count;
     Assert.AreEqual(2, count, "List count should be 2 after adding two elements.");
 }
Exemple #28
0
        public void RemoveAtIncorrectIndexShoudThrowArgumentNullException()
        {
            var list = new DynamicList <int>();

            list.Add(2);
            list.Add(6);
            list.RemoveAt(2);
        }
Exemple #29
0
 public void TestAddingNodeOnNonExistingPositivePositionMustThrowArgumentOutOfRangeException()
 {
     var list = new DynamicList<int>();
     list.Add(1);
     list.Add(1);
     list.Add(1);
     list[3] = 3;
 }
        public void ListElementsCheckingElementNotInTheListShoudNotContainElement()
        {
            var list = new DynamicList<int>();
            list.Add(1);
            list.Add(2);

            Assert.IsFalse(list.Contains(6), "The list must not contain 6.");
        }
        public void TestRemoveAtOnIndexGreaterThanCount()
        {
            DynamicList <int> list = new DynamicList <int>();

            list.Add(0);
            list.Add(1);
            list.RemoveAt(2);
        }
 public void TestCountAfterTwoElementsAdded()
 {
     var list = new DynamicList<int>();
     list.Add(1);
     list.Add(2);
     var count = list.Count;
     Assert.AreEqual(2, count, "List count should be 2 after adding two elements.");
 }
Exemple #33
0
        public void GetElementWithIncorrectIndexShoudThrowArgumentNullException()
        {
            var list = new DynamicList <int>();

            list.Add(2);
            list.Add(6);
            int element = list[2];
        }
 public void RemoveShouldThrowExceptionIfIndexIsNotPresent()
 {
     DynamicList<int> list = new DynamicList<int>();
     list.Add(2);
     list.Add(3);
     list.Add(4);
     list.RemoveAt(4);
 }
 public void TestRemoveAt_ValidIndex_ShouldReturnProperElement()
 {
     var list = new DynamicList<int>();
     list.Add(5);
     list.Add(15);
     var element = list.RemoveAt(1);
     Assert.AreEqual(15, element);
 }
Exemple #36
0
        public void AddMethod_ShouldAddAfterValues()
        {
            DynamicList <int> testList = new DynamicList <int>();

            testList.Add(4);
            testList.Add(123);

            Assert.That(testList[testList.Count - 1], Is.EqualTo(123));
        }
        public void AddingElementShouldContainElement()
        {
            var list = new DynamicList<int>();
            list.Add(1);
            list.Add(2);
            list.Add(6);

            Assert.IsTrue(list.Contains(6), "The list must contain 6.");
        }
Exemple #38
0
 public void TestCount_ValidCountOnTwoItemsInList_ExpectSuccess()
 {
     DynamicList<int> list = new DynamicList<int>();
     list.Add(5);
     list.Add(7);
     int actual = list.Count;
     int expected = 2;
     Assert.AreEqual(expected, actual, "List count should be 2.");
 }
Exemple #39
0
 public void TestIndexator_GetValid_ExpectSuccess()
 {
     DynamicList<int> list = new DynamicList<int>();
     list.Add(5);
     list.Add(8);
     int actual = list[1];
     int expected = 8;
     Assert.AreEqual(expected, actual, "Item on index 1 should be 8.");
 }
        public void GetingElementAtCorrectPositionFromNoneEmptyDynamicListOfIntsShouldReturnCorrectElement()
        {
            var dynamicListOfInts = new DynamicList<int>();
            dynamicListOfInts.Add(1);
            dynamicListOfInts.Add(2);
            dynamicListOfInts.Add(3);

            Assert.AreEqual(3, dynamicListOfInts[2], "Obtained value of getting a element whit operator \"[]\" is not as expected\nNote that position couting should start from 0!");
        }           
Exemple #41
0
        public void TestAddTwoElementsAndCheckIfTheyAreIndexedCorrectly()
        {
            DynamicList <int> list = new DynamicList <int>();

            list.Add(5);
            list.Add(2);
            Assert.AreEqual(5, list[0]);
            Assert.AreEqual(2, list[1]);
        }
Exemple #42
0
        public void RemoveShouldThrowExceptionIfIndexIsNotPresent()
        {
            DynamicList <int> list = new DynamicList <int>();

            list.Add(2);
            list.Add(3);
            list.Add(4);
            list.RemoveAt(4);
        }
        public void TestCountAfterAddingTwoItems()
        {
            DynamicList <int> list = new DynamicList <int>();

            list.Add(2);
            list.Add(3);

            Assert.AreEqual(2, list.Count);
        }
        public void IndexOf_NonExistantItem_ShouldReturnNegativeOne()
        {
            list.Add(42);

            int actual   = list.IndexOf(100);
            int expected = -1;

            Assert.AreEqual(expected, actual);
        }
        public void RemoveAt_ShouldThrowAnException_WhenTheIndex_IsOutOfRange()
        {
            var dynamicList = new DynamicList<string>();
            dynamicList.Add("Kori");
            dynamicList.Add("Moti4kata");
            dynamicList.Add("allahuakbar");

            dynamicList.RemoveAt(4);
        }
        public void RemovingElementAtOutOfRangePositionFromNoneEmptyDynamicListOfIntsShouldThrowException()
        {
            var dynamicListOfInts = new DynamicList<int>();
            dynamicListOfInts.Add(1);
            dynamicListOfInts.Add(2);
            dynamicListOfInts.Add(3);

            dynamicListOfInts.RemoveAt(4);
        }
        public void SettingElementAtOutOfRangePositionInNoneEmptyDynamicListOfIntsShouldThrowException()
        {
            var dynamicListOfInts = new DynamicList<int>();
            dynamicListOfInts.Add(1);
            dynamicListOfInts.Add(2);
            dynamicListOfInts.Add(3);

            dynamicListOfInts[4] = 4;
        } 
Exemple #48
0
 public void TestIndexator_SetValid_ExpectSuccess()
 {
     DynamicList<int> list = new DynamicList<int>();
     list.Add(5);
     list.Add(8);
     list[1] = 3;
     int expected = 3;
     Assert.AreEqual(expected, list[1], "Item on index 1 should be 3.");
 }
        public void TestCountAfterRemoveNonExistingElementFromList()
        {
            DynamicList<string> list = new DynamicList<string>();
            list.Add("one");
            list.Add("two");
            int count = list.Count;

            Assert.AreEqual(2, count, "The count of the list should remain unchanged after trying to remove a non-existing element.");
        }
        public void AddingThreeElementsCountShouldBeThree()
        {
            var list = new DynamicList<int>();
            list.Add(1);
            list.Add(2);
            list.Add(3);

            Assert.AreEqual(3, list.Count, "The counter is not 3 its " + list.Count);
        }
        public void TestAddTwoElementsAndCheckIfTheyAreIndexedCorrectly()
        {
            DynamicList<int> list = new DynamicList<int>();

            list.Add(5);
            list.Add(2);
            Assert.AreEqual(5, list[0]);
            Assert.AreEqual(2, list[1]);
        }
Exemple #52
0
        public void ListShouldAddElementAtEnd()
        {
            intDynamicList = new DynamicList <int>();
            intDynamicList.Add(100);
            Assert.AreEqual(100, intDynamicList[0], "List cannot add element");

            intDynamicList.Add(200);
            Assert.AreEqual(200, intDynamicList[1], "List cannot add element at the end");
        }
Exemple #53
0
        public void ListElementsCheckingElementNotInTheListShoudNotContainElement()
        {
            var list = new DynamicList <int>();

            list.Add(1);
            list.Add(2);

            Assert.IsFalse(list.Contains(6), "The list must not contain 6.");
        }
        public void AddTest()
        {
            DynamicList<int> list = new DynamicList<int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);

            Assert.AreEqual(3, list[2], "List does not add items correctly");
        }
        public void TestContainsOnNonExisingElement()
        {
            DynamicList<string> list = new DynamicList<string>();
            list.Add("first");
            list.Add("second");

            bool isFound = list.Contains("third");

            Assert.IsFalse(isFound, "The element is not in the list and Contains should return false.");
        }
        public void CountTest()
        {
            DynamicList<int> list = new DynamicList<int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);

            Assert.AreEqual(3, list.Count, "Count does not count the elements correctly");
        }
        public void IndexTest()
        {
            DynamicList<int> list = new DynamicList<int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);

            Assert.AreEqual(3, list[2], "List indexation is incorrect");
        }
        public void IndexTest_IndexOutOfRange_ShouldThrowArgumentOutOfRangeException()
        {
            DynamicList<int> list = new DynamicList<int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);

            var element = list[5];
        }
        public void Add_ShouldIncrementTheCount()
        {
            var linkedList = new DynamicList<int>();

            linkedList.Add(5);
            linkedList.Add(4);
            linkedList.Add(3);

            Assert.AreEqual(3, linkedList.Count, "The count is not being incremented within the Dynamic List.");
        }
        public void Remove_ShouldReturnMinusOneWhenTheElementIsNotFound()
        {
            var dynamicList = new DynamicList<string>();
            dynamicList.Add("Kori");
            dynamicList.Add("Moti4kata");
            dynamicList.Add("allahuakbar");

            var returnedValue = dynamicList.Remove("Kiro");
            Assert.AreEqual(-1,returnedValue, "The method .Remove isn't removing the element properly.");
        }