Beispiel #1
0
        public void Create_SVBlock_from_SV_string_with_sub_block()
        {
            const string fileContent = @"[ELB samples = 3 patterns = 5]
[SV 0 0 0 0 0 0 1 0 1 1 1 0 1]
DND
DDC
DAN
ANN
ADD
[ELB samples = 3 patterns = 5]
[SV 0 0 0 0 0 0 0 1 1 1 1 0 1]
CDD
DNC
DDN
DAD
AND
[ELB samples = 3 patterns = 5]
[SV 0 0 0 0 0 0 0 1 0 1 1 0 1]
CDD
DNC
DDN
DAD
AND
[ELB samples = 3 patterns = 5]
[SV 0 0 0 0 0 0 0 1 1 1 1 0 1]
CDD
DNC
DDN
DAD
AND";
            var          blocks      = new List <SVBlock>();
            const int    patterns    = 5;

            using (var reader = new StringReader(fileContent))
            {
                while (true)
                {
                    var line = reader.ReadLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }
                    if (line.StartsWith("[SV"))
                    {
                        var svVector = SVVector.FromSV(line);
                        var words    = Enumerable.Range(0, patterns).Select(_ => reader.ReadLine());
                        var block    = SVBlock.FromSV(svVector, words);
                        blocks.Add(block);
                    }
                }
            }

            var blockList = new SVBlockList(blocks);
            var svKeys    = blockList.Keys.ToArray();

            Assert.Equal(new[]
            {
                "[SV 0 0 0 0 0 0 0 1 1 1 1 0 1]",
                "[SV 0 0 0 0 0 0 1 0 1 1 1 0 1]"
            },
                         svKeys);
        }