Beispiel #1
0
        public MatrixIndicator Post([FromBody] int[][] array)
        {
            var selectFromArray = from j in Enumerable.Range(0, array.Length)
                                  from i in Enumerable.Range(0, array[j].Length)
                                  where array[j][i] > 0
                                  select(I: i, J: j);

            return(MatrixIndicator.Create(selectFromArray.ToArray(), t => t.I, t => t.J));
        }
        public void ConvertFromStringTest(string input)
        {
            var array = new[]
            {
                new [] { 0, 0, 0, 0, 0, 0, 0 }, // Y = 0
                new [] { 0, 0, 1, 0, 1, 1, 1 }, // Y = 1
                new [] { 0, 0, 0, 0, 0, 0, 0 }, // Y = 2
                new [] { 0, 0, 1, 0, 0, 0, 0 }, // Y = 3
                new [] { 0, 0, 1, 0, 0, 0, 0 }, // Y = 4
                new [] { 0, 1, 0, 0, 0, 0, 0 }, // Y = 5
                new [] { 0, 0, 1, 0, 0, 0, 0 }, // Y = 6
            };
            var selectFromArray = from j in Enumerable.Range(0, array.Length)
                                  from i in Enumerable.Range(0, array[j].Length)
                                  where array[j][i] > 0
                                  select(I: i, J: j);
            var expected = MatrixIndicator.Create(selectFromArray.ToArray(), t => t.I, t => t.J).AsEnumerable(ValueTuple.Create).ToHashSet();
            var actual   = MatrixIndicator.Parse(input).AsEnumerable(ValueTuple.Create).ToHashSet();

            Assert.Equal(expected, actual);
        }