Пример #1
0
        public void Get_GetNumbersFromEmptyRingBufferShouldThrowExeption()
        {
            // Arrange
            RingBufferLinkedList <int> sut = new RingBufferLinkedList <int>(5);

            // Act

            // Assert
            Assert.Throws <DataStructureIsEmptyOnReadExeption>(() => sut.Get());
        }
Пример #2
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));
        }
Пример #3
0
        public void Indexer_SetFromWrongIndexShouldThrowExeption()
        {
            // Arrange
            RingBufferLinkedList <double> sut = new RingBufferLinkedList <double>(10)
            {
                1,
                2
            };

            // Act

            // Assert
            Assert.Throws <IndexOutOfRangeException>(() => sut[5] = 10);
        }
Пример #4
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);
        }
Пример #5
0
        public void Filter_FilterShouldWork()
        {
            // Arrange
            RingBufferLinkedList <int> sut = new RingBufferLinkedList <int>(10)
            {
                4, 2, 3, 5, 1, 2
            };

            int[] expected = { 4, 5 };

            // Act
            IEnumerable <int> actual = sut.Filter(item => item >= 4);

            // Assert
            Assert.Equal(expected, actual);
        }
Пример #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);
        }
Пример #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);
        }
Пример #8
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);
        }
Пример #9
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);
        }
Пример #10
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);
        }