コード例 #1
0
        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);
        }
コード例 #2
0
        public void StaticListGetalueWithBracketsIllegalIndexThrowsException()
        {
            //Arrange
            var list     = new StaticList <int>();
            var expected = new int[] { 2, 3 };

            //Act
            list.Add(8);
            list.Add(7);
            var result = list[14];
            //Assert
        }
コード例 #3
0
        public void StaticListCountsCorrectly()
        {
            //Arrange
            var list          = new StaticList <int>();
            var expectedCount = 2;

            //Act
            list.Add(1);
            list.Add(2);
            int count = list.Count();

            //Assert
            Assert.AreEqual(expectedCount, count);
        }
コード例 #4
0
        public void StaticListAddsCorrectly()
        {
            //Arrange
            var list = new StaticList <int>();

            //Act
            list.Add(1);
            list.Add(2);
            var array = list.ToArray();

            //Assert
            CollectionAssert.Contains(array, 1);
            CollectionAssert.Contains(array, 2);
        }
コード例 #5
0
        public void StaticListChangeValueWithBracketsWorksCorrectly()
        {
            //Arrange
            var list     = new StaticList <int>(5);
            var expected = new int[] { 2, 3 };

            list.Add(8);
            list.Add(7);

            //Act
            list[0] = 1;
            list[1] = 3;
            list[0] = 2;
            var result = list.ToArray();

            //Assert
            CollectionAssert.AreEqual(expected, result);
        }
コード例 #6
0
        public unsafe void TestStaticList()
        {
            int *ptr  = stackalloc int[16];
            var  list = new StaticList(ptr);

            Assert.IsTrue(ptr == list.Waterline);
            list.Add(2);
            Assert.IsTrue(ptr + 1 == list.Waterline);
            Assert.IsTrue(list[0] == 2);
            list.Pop();
            Assert.IsTrue(ptr == list.Waterline);
        }
コード例 #7
0
        public void StaticListIndexOfWorksCorrectly()
        {
            //Arrange
            var list     = new StaticList <int>();
            int expected = 2;

            //Act
            list.Add(1);
            list.Add(2);
            list.Add(88);
            list.Add(64);
            list.Add(54);
            list.Add(200);
            list.Add(132);

            int result = list.IndexOf(88);

            //Assert
            Assert.AreEqual(expected, result);
        }
コード例 #8
0
        public void StaticListContainsItemCorrectly()
        {
            //Arrange
            var list = new StaticList <int>();

            //Act
            list.Add(1);
            list.Add(2);
            list.Add(88);
            list.Add(64);
            list.Add(54);
            list.Add(200);
            list.Add(132);
            bool contains       = list.Contains(54);
            bool doesNotContain = list.Contains(53);

            //Assert
            Assert.IsTrue(contains);
            Assert.IsFalse(doesNotContain);
        }
コード例 #9
0
        public void StaticListRemoveAtIllegalIndexThrowsException()
        {
            //Arrange
            var list     = new StaticList <int>();
            var expected = new int[] { 8, 7, 3, 1, 6 };

            //Act
            list.Add(8);
            list.Add(7);
            list.Add(11);
            list.Add(3);
            list.Add(1);
            list.Add(6);

            list.RemoveAt(11);
            //Assert
        }
コード例 #10
0
        public void StaticListRemoveWorksCorrectly()
        {
            //Arrange
            var list     = new StaticList <int>();
            var expected = new int[] { 8, 7, 3, 1, 6 };

            //Act
            list.Add(8);
            list.Add(7);
            list.Add(11);
            list.Add(3);
            list.Add(1);
            list.Add(6);

            list.Remove(11);
            var result = list.ToArray();

            //Assert
            CollectionAssert.AreEqual(expected, result);
        }
コード例 #11
0
        public void StaticListCopyToWorksCorrectly()
        {
            //Arrange
            var list     = new StaticList <int>();
            var expected = new int[] { 8, 7, 11, 3, 1, 6 };
            var result   = new int[6];

            //Act
            list.Add(8);
            list.Add(7);
            list.Add(11);
            list.Add(3);
            list.Add(1);
            list.Add(6);

            list.CopyTo(result, 0);

            //Assert
            CollectionAssert.AreEqual(expected, result);
        }
コード例 #12
0
 public void Foo()
 {
     StaticList.Add(12345);
 }