예제 #1
0
        public void GetItemsTest1()
        {
            RectMatrix <string, int> matrix = new RectMatrix <string, int>();

            matrix.EnsureSize(4, 3);
            matrix[0, 0]               = "a";
            matrix[0, 1]               = "b";
            matrix[0, 2]               = "c";
            matrix[1, 0]               = "d";
            matrix[1, 1]               = "e";
            matrix[1, 2]               = "f";
            matrix[2, 0]               = "g";
            matrix[2, 1]               = "h";
            matrix[2, 2]               = "i";
            matrix[3, 0]               = "j";
            matrix[3, 1]               = "k";
            matrix[3, 2]               = "l";
            matrix.RowAttributes[0]    = 2;
            matrix.RowAttributes[1]    = 4;
            matrix.RowAttributes[2]    = 6;
            matrix.RowAttributes[3]    = 8;
            matrix.ColumnAttributes[0] = 12;
            matrix.ColumnAttributes[1] = 8;
            matrix.ColumnAttributes[2] = 4;
            var result = matrix.GetItems((row, column, rowAttribute, columnAttribute, x) => (rowAttribute > 3 && rowAttribute < 7 && columnAttribute < 9) || rowAttribute == 8);

            CollectionAssertEx.AreEqual(new string[] { "e", "f", "h", "i", "j", "k", "l" }, result);
        }
예제 #2
0
        public void GetItemsGuardTest()
        {
            RectMatrix <string, int> matrix = new RectMatrix <string, int>();

            matrix.EnsureSize(1, 1);
            matrix[0, 0] = "1";
            var result = matrix.GetItems(null).ToList();
        }
예제 #3
0
        public void GetItemsTest2()
        {
            RectMatrix <int, int> matrix = new RectMatrix <int, int>();

            matrix.EnsureSize(3, 2);
            matrix[0, 0]               = 2;
            matrix[0, 1]               = 7;
            matrix[1, 0]               = 3;
            matrix[1, 1]               = 5;
            matrix[2, 0]               = 8;
            matrix[2, 1]               = 0;
            matrix.RowAttributes[0]    = 1;
            matrix.RowAttributes[1]    = 2;
            matrix.RowAttributes[2]    = 3;
            matrix.ColumnAttributes[0] = 4;
            matrix.ColumnAttributes[1] = 10;
            List <int> rowIndexList    = new List <int>();
            List <int> columnIndexList = new List <int>();
            var        result          = matrix.GetItems((row, column, rowAttribute, columnAttribute, x) => { rowIndexList.Add(row); columnIndexList.Add(column); return(columnAttribute > 5); }).ToList();

            CollectionAssert.AreEqual(new int[] { 0, 0, 1, 1, 2, 2 }, rowIndexList);
            CollectionAssert.AreEqual(new int[] { 0, 1, 0, 1, 0, 1 }, columnIndexList);
        }