Esempio n. 1
0
        public void Add_AddNumbersToFullRingBufferShouldNotWork()
        {
            // Arrange
            RingBufferLinkedList <int> sut = new RingBufferLinkedList <int>(5);

            // Act
            for (int i = 0; i < 5; i++)
            {
                sut.Add(i);
            }

            // Assert
            Assert.Throws <DataStructureIsFullOnInsertExeption>(() => sut.Add(6));
        }
Esempio n. 2
0
        public void Add_AddSomeNumbersToRingBufferShouldWork()
        {
            // Arrange
            RingBufferLinkedList <int> sut = new RingBufferLinkedList <int>(3);
            int expected = 3;

            // Act
            sut.Add(11);
            sut.Add(12);
            sut.Add(13);
            int actual = sut.Size();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 3
0
        public void Get_AddAndGetSomeNumbersShouldWork()
        {
            // Arrange
            RingBufferLinkedList <int> sut = new RingBufferLinkedList <int>(5);
            int expected = 42;

            // Act
            sut.Add(12);
            sut.Add(15);
            sut.Add(42);
            sut.Get();
            sut.Add(48);
            sut.Get();
            int actual = sut.Get();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 4
0
        public void Expand_ExpandRingBufferShouldWork()
        {
            // Arrange
            RingBufferLinkedList <int> sut = new RingBufferLinkedList <int>(3);
            int expected = 5;

            // Act
            sut.Add(1);
            sut.Add(2);
            sut.Add(3);
            sut.Expand(2);
            sut.Add(4);
            sut.Add(5);
            int actual = sut.Size();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 5
0
        public void Enumerable_EnumShouldWork()
        {
            // Arrange
            RingBufferLinkedList <int> sut = new RingBufferLinkedList <int>(5);

            int[] arr = new int[3];

            // Act
            sut.Add(1);
            sut.Add(2);
            sut.Add(3);

            int i = 0;

            foreach (var item in sut)
            {
                arr[i] = item;
                i++;
            }

            // Assert

            Assert.Equal(new int[] { 1, 2, 3 }, arr);
        }
Esempio n. 6
0
        public void Clear_ClearRingBufferShouldWork()
        {
            // Arrange
            RingBufferLinkedList <int> sut = new RingBufferLinkedList <int>(100);
            bool expected = true;

            // Act
            for (int i = 0; i < 100; i++)
            {
                sut.Add(i);
            }
            sut.Clear();
            bool actual = sut.IsEmpty();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 7
0
        public void Indexer_IndexerGetAndSetFromEndShouldWork()
        {
            // Arrange
            RingBufferLinkedList <double> sut = new RingBufferLinkedList <double>(10);
            double expected = 42.2;

            // Act
            for (int i = 0; i < 10; i++)
            {
                sut.Add(i);
            }
            sut[9] = 42.2;
            double actual = sut[9];

            // Assert
            Assert.Equal(expected, actual);
        }