示例#1
0
文件: TokenChecks.cs 项目: flq/rfb
 public void BacktickTokenWorks()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("backtick check.txt"));
       handle.FastForwardToLine(3);
       var t = handle.ProcessWithToken<BacktickToken>();
       t.BackTickValue.ShouldBeEqualTo("echo y| cacls %(Binaries.Identity) /G everyone:R");
 }
示例#2
0
文件: CommentToken.cs 项目: flq/rfb
 protected override AbstractToken handle(TokenizerHandle handle)
 {
     if (!commentMatch.IsMatch(handle.CurrentLine))
     return null;
       handle.CurrentHandled();
       return this;
 }
示例#3
0
文件: TokenChecks.cs 项目: flq/rfb
 public void ADashCanBeEscaped()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("_scriptNeedingDashEscaping.txt"));
       handle.FastForwardToLine(5);
       var t = handle.ProcessWithToken<AnyToken>();
       t["ZipFileName"].ShouldBeEqualTo("ber-$(currentTag).zip");
 }
示例#4
0
文件: TokenChecks.cs 项目: flq/rfb
 public void NodeWithOptionsHasIndexer()
 {
     var handle = new TokenizerHandle(DataMother.GetEmptyProjectFile());
       handle.FastForwardToLine(1);
       var t = handle.ProcessWithToken<ProjectToken>();
       t["DefaultTargets"].ShouldBeEqualTo("Main");
       t["Bla"].ShouldBeNull();
 }
示例#5
0
文件: TokenChecks.cs 项目: flq/rfb
 public void PowershellScriptCallToken()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("_scriptWithPowershellExecAsTask.txt"));
       handle.FastForwardToLine(4);
       var t = handle.ProcessWithToken<PSScriptCallToken>();
       t.ShouldNotBeNull();
       t.Word.ShouldBeEqualTo("MakeFile");
 }
示例#6
0
文件: TokenChecks.cs 项目: flq/rfb
 public void NodeWithOptionsEscapesDefault()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("node with default needs escaping.txt"));
       handle.FastForwardToLine(1);
       var t = handle.ProcessWithToken<ProjectToken>();
       t["Default"].ShouldBeEqualTo("Default stuff \" Hoho");
       t.Options.Count.ShouldBeEqualTo(4);
 }
示例#7
0
文件: TokenChecks.cs 项目: flq/rfb
 public void DefaultOptionMapping()
 {
     var handle = new TokenizerHandle(DataMother.NodeWithOptionsVariantB());
       handle.FastForwardToLine(1);
       var t = handle.ProcessWithToken<ProjectToken>();
       t.MapDefaultTo("Option1");
       t["Default"].ShouldBeNull();
       t["Option1"].ShouldNotBeNull();
 }
示例#8
0
 protected override void withinHandle(TokenizerHandle tHandle)
 {
     var typeOfOutput = tHandle.CurrentLine.TrimStart(' ', '\t').Substring(0, 1);
       if (typeOfOutput == "@")
     ValueType = PSScriptReturnValueType.ItemGroup;
       else if (typeOfOutput == "$")
     ValueType = PSScriptReturnValueType.Property;
       else
     throw new InvalidOperationException("Impossible! No way!");
 }
示例#9
0
 protected override AbstractToken handle(TokenizerHandle handle)
 {
     var match = psScriptStart.Match(handle.CurrentLine);
       if (match.Groups.Count != 2)
     return null;
       Terminator = match.Groups[1].Value;
       extractScript(handle);
       handle.CurrentHandled();
       return this;
 }
示例#10
0
文件: BacktickToken.cs 项目: flq/rfb
 protected override AbstractToken handle(TokenizerHandle handle)
 {
     var match = matchBacktick.Match(handle.CurrentLine);
       if (match.Groups.Count > 1)
       {
     BackTickValue = match.Groups[1].Value;
     handle.CurrentHandled();
     return this;
       }
       return null;
 }
示例#11
0
文件: AbstractToken.cs 项目: flq/rfb
 public IToken Check(TokenizerHandle handle)
 {
     var t = this.handle(handle);
       if (t!= null)
       {
     var returnToken = t.Clone();
     t.reset();
     return returnToken;
       }
       return null;
 }
示例#12
0
 public void TokenHandleReturnsEmptyStringOnceItIsRunOut()
 {
     var th = new TokenizerHandle("hello" + Environment.NewLine + "world");
       th.Advance();
       th.CurrentLine.ShouldBeEqualTo("hello");
       th.CurrentHandled();
       th.Advance();
       th.CurrentLine.ShouldBeEqualTo("world");
       th.CurrentHandled();
       th.Advance();
       th.CurrentLine.ShouldBeNull();
 }
示例#13
0
        protected override AbstractToken handle(TokenizerHandle tHandle)
        {
            var m = matchRegEx.Match(tHandle.CurrentLine);
              if (m.Groups.Count == 0 || m.Groups.Count != 3)
            return null;

              VariableName = m.Groups[1].Captures[0].Value.Trim(' ');
              Value = m.Groups[2].Captures[0].Value.Trim(' ');
              tHandle.CurrentHandled();
              withinHandle(tHandle);
              return this;
        }
示例#14
0
文件: TokenChecks.cs 项目: flq/rfb
        public void NodeWithOptionsWorksAsExpected()
        {
            var handle = new TokenizerHandle(DataMother.GetNodeWithOptions());
              handle.FastForwardToLine(1);
              var t = handle.ProcessWithToken<ProjectToken>();

              t.ShouldNotBeNull();
              t.Options.ShouldHaveCount(4);
              t.Options["Default"].StartsWith("Default").ShouldBeTrue();
              t.Options["Option1"].ShouldBeEqualTo("Bla di Bla");
              t.Options["Option3"].ShouldBeEqualTo("Blablub");
        }
示例#15
0
文件: PSScriptToken.cs 项目: flq/rfb
 protected void extractScript(TokenizerHandle h)
 {
     h.CurrentHandled();
       h.Advance();
       var rEnd = new Regex(@"\s*" + Terminator);
       var b = new StringBuilder();
       while (!rEnd.IsMatch(h.CurrentLine))
       {
     b.AppendLine(h.CurrentLine);
     h.CurrentHandled();
     h.Advance();
       }
       Script = b.ToString();
 }
示例#16
0
文件: TokenChecks.cs 项目: flq/rfb
        public void TargetTokenWorksAsExpected()
        {
            var handle = new TokenizerHandle(DataMother.ProjectAndTarget());
              handle.FastForwardToLine(3);

              var t = handle.ProcessWithToken<TargetToken>();
              t.ShouldNotBeNull();
              t.Options.ShouldHaveCount(2);
              t.Options["Default"].StartsWith("Default").ShouldBeTrue();
              t.Options["Depends"].StartsWith("Deps").ShouldBeTrue();
        }
示例#17
0
文件: TokenChecks.cs 项目: flq/rfb
        public void ProjectTokenWorksAsExpectedVariantB()
        {
            var handle = new TokenizerHandle(DataMother.NodeWithOptionsVariantB());
              handle.FastForwardToLine(1);
              var t = handle.ProcessWithToken<ProjectToken>();

              t.ShouldNotBeNull();
              t.Options.Count.ShouldBeEqualTo(3);
        }
示例#18
0
文件: TokenChecks.cs 项目: flq/rfb
 public void VariableTokenWorksAsExpected()
 {
     var handle = new TokenizerHandle(DataMother.ProjectAndTarget());
       handle.FastForwardToLine(2);
       var t = handle.ProcessWithToken<VariableToken>();
       t.ShouldNotBeNull();
       t.VariableName.ShouldBeEqualTo("Foo");
       t.Value.ShouldBeEqualTo("Bar Baz");
 }
示例#19
0
文件: AbstractToken.cs 项目: flq/rfb
 protected abstract AbstractToken handle(TokenizerHandle handle);
示例#20
0
文件: TokenChecks.cs 项目: flq/rfb
 public void ProjectTokenDoesNotGobbleOptionsOfTargetToken()
 {
     var handle = new TokenizerHandle(DataMother.ProjectAndTarget());
       handle.FastForwardToLine(1);
       var t = handle.ProcessWithToken<ProjectToken>();
       t.Options.ShouldHaveCount(1);
 }
示例#21
0
文件: TokenChecks.cs 项目: flq/rfb
 public void PowershellScriptToken()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("_scriptWithPowershell.txt"));
       handle.FastForwardToLine(7);
       var t = handle.ProcessWithToken<PSExternalScriptToken>();
       t.ScriptName.ShouldBeEqualTo("smallPNGs");
       t.Script.IndexOf("echo").ShouldBeSmallerThan(5);
       t.Script.Contains("FullName").ShouldBeTrue();
       t.Terminator.ShouldBeEqualTo("END");
 }
示例#22
0
文件: TokenChecks.cs 项目: flq/rfb
 public void PowershellScriptCallTokenNotMatchingScriptDef()
 {
     var handle = new TokenizerHandle(DataMother.GetFile("_scriptWithPowershell.txt"));
       handle.FastForwardToLine(7);
       var t = handle.ProcessWithToken<PSScriptCallToken>();
       t.ShouldBeNull();
 }
示例#23
0
 private static AnyToken asNodeWithOptions(AbstractDefinedValueToken varToken)
 {
     var h = new TokenizerHandle(varToken.Value);
     h.Advance();
     var anyToken = new AnyToken();
     anyToken = (AnyToken) anyToken.Check(h);
     if (anyToken == null)
       throw new ArgumentException("Value to " + varToken.VariableName + " could not be understood.");
     return anyToken;
 }
示例#24
0
文件: TokenChecks.cs 项目: flq/rfb
        public void ProjectTokenWorksAsExpected()
        {
            var handle = new TokenizerHandle("Project \"Main\"");
              handle.FastForwardToLine(1);
              var t = handle.ProcessWithToken<ProjectToken>();

              t.ShouldNotBeNull();
              t.Options.Count.ShouldBeEqualTo(1);
              t.Word.ShouldBeEqualTo("Project");
        }
示例#25
0
 protected virtual void withinHandle(TokenizerHandle tHandle)
 {
 }
示例#26
0
文件: EndToken.cs 项目: flq/rfb
 public IToken Check(TokenizerHandle handle)
 {
     return null;
 }