Exemplo n.º 1
0
 static Connector()
 {
     FileHelper = new FileHelper();
     PatternParser = new PatternParser();
     PatternNormalizer = new PatternNormalizer();
     PatternValidator = new PatternValidator();
     PatternDispatcher = new PatternDispatcher();
 }
 public void SetUp()
 {
     var patternParser = new PatternParser();
     data = patternParser.Parse(Pattern);
     patternNormalizer = new PatternNormalizer();
 }
        public void IsTypesValidFailTest(string pattern, string error)
        {
            var patternParser = new PatternParser();
            var data = patternParser.Parse(pattern);

            var result = patternValidator.IsTypesValid(data);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result.First(), Is.EqualTo(error));
        }
        public void IsTypesValidTest()
        {
            const string pattern = @",Gate0,Leg1,Gate1,Leg2,Gate2,Leg3,Gate3,Leg4,Gate4
            A,B1; S1,10,SX1,20,N,10,N,20,N
            B,,,,,,,,-20,N
            C,,,,,,-10,N,30,N
            D,,,,,,,,-30,N
            E,,,,-20,S2,20,B3; SX2,20,BX1; BX3
            F,,,,,,,,-20,BX3
            G,,,,,,-20,SX2,10,N
            H,,,,,,,,-10,N
            I,,-10,B2; BX1,30,SX1,20,N,10,BX2
            J,,,,,,,,-10,BX2
            K,,,,,,-20,N,20,BX2
            L,,,,,,,,-20,BX2
            M,,,,-30,N,10,SX1,30,BX2
            N,,,,,,,,-30,BX2
            O,,,,,,-10,N,20,BX2; SX1
            P,,,,,,,,-20,BX2; SX1";

            var patternParser = new PatternParser();
            var data = patternParser.Parse(pattern);

            var result = patternValidator.IsTypesValid(data);

            Assert.That(result.Count, Is.EqualTo(0));
        }
        public void IsSizeValidRowLengthFailTest(string pattern, string rowName)
        {
            var patternParser = new PatternParser();
            var data = patternParser.Parse(pattern);

            var result = patternValidator.IsSizeValid(data);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result.First(), Is.EqualTo(string.Format("Pattern row: {0} is invalid", rowName)));
        }
        public void IsSyntaxValidTest()
        {
            const string pattern = @",Gate0,Leg1,Gate1,Leg2,Gate2,Leg3,Gate3,Leg4,Gate4
            A,B1; B2;S1;S2,10,BX1; BX2,20,N,10,N,20,N
            B,,,,,,,,-20,N
            C,,,,,,-10,N,30,N
            D,,,,,,,,-30,N
            E,,,,-20,N,20,N,20,N
            F,,,,,,,,-20,N
            G,,,,,,-20,N,10,N
            H,,,,,,,,-10,N
            I,,-10,SX1;SX2,30,N,20,N,10,N
            J,,,,,,,,-10,N
            K,,,,,,-20,N,20,N
            L,,,,,,,,-20,N
            M,,,,-30,N,10,N,30,N
            N,,,,,,,,-30,N
            O,,,,,,-10,N,20,N
            P,,,,,,,,-20,N";

            var patternParser = new PatternParser();
            var data = patternParser.Parse(pattern);

            var result = patternValidator.IsSyntaxValid(data);

            Assert.That(result.Count, Is.EqualTo(0));
        }
Exemplo n.º 7
0
        public void RemoveTitleRowWithExceptionTest(List<string> input, List<string> output)
        {
            var patternParser = new PatternParser();

            var result = patternParser.RemoveTitleRow(input);

            Assert.That(result, Is.EqualTo(output));
        }
        public void IsCloseActionPositionValidFailTest(string pattern, string error)
        {
            var patternParser = new PatternParser();
            var data = patternParser.Parse(pattern);
            var patternNormalizer = new PatternNormalizer();
            data = patternNormalizer.TransferDownPattern(data);

            var result = patternValidator.IsCloseActionPositionValid(data);

            Assert.That(result.Count, Is.EqualTo(1));
            Assert.That(result.First(), Is.EqualTo(error));
        }
Exemplo n.º 9
0
        public void RemoveTitleColumnTest(List<List<string>> input, List<List<string>> output)
        {
            var patternParser = new PatternParser();

            var result = patternParser.RemoveTitleColumn(input);

            Assert.That(result, Is.EqualTo(output));
        }
Exemplo n.º 10
0
        public void RemoveSpacesTest(string input, string output)
        {
            var patternParser = new PatternParser();

            var result = patternParser.RemoveSpaces(input);

            Assert.That(result, Is.EqualTo(output));
        }
Exemplo n.º 11
0
        public void ParseOriginalDataTest()
        {
            var patternParser = new PatternParser();

            var columns = patternParser.Parse(Pattern);

            Assert.That(columns.First().First(), Is.EqualTo("B1;S1"));
            Assert.That(columns.First().Last(), Is.EqualTo("N"));
            Assert.That(columns.Last().First(), Is.EqualTo(""));
            Assert.That(columns.Last().Last(), Is.EqualTo("BX2;SX1"));
        }
Exemplo n.º 12
0
        public void GetRowsTest(string input, List<string> output)
        {
            var patternParser = new PatternParser();

            var result = patternParser.GetRows(input);

            Assert.That(result, Is.EqualTo(output));
        }
Exemplo n.º 13
0
        public void GetColumnsTest(List<string> input, List<string[]> output)
        {
            var patternParser = new PatternParser();

            var result = patternParser.GetColumns(input);

            Assert.That(result, Is.EqualTo(output));
        }