public void ShouldParseService_multi()
        {
            var sr     = new StringWrapper("  ##teamcity[name a='z']\r##teamcity[zzz 'z']\n##teamcity[name a='z']  ");
            var result = new ServiceMessageParser().ParseServiceMessages(sr).ToArray();

            Assert.AreEqual(3, result.Length);

            var msg = result[0];

            Assert.AreEqual("name", msg.Name);
            Assert.AreEqual(1, msg.Keys.Count());
            Assert.AreEqual(new HashSet <string> {
                "a"
            }, new HashSet <string>(msg.Keys));
            Assert.AreEqual(null, msg.DefaultValue);
            Assert.AreEqual("z", msg.GetValue("a"));

            msg = result[1];
            Assert.AreEqual("zzz", msg.Name);
            Assert.AreEqual(0, msg.Keys.Count());
            Assert.AreEqual("z", msg.DefaultValue);

            msg = result[2];
            Assert.AreEqual("name", msg.Name);
            Assert.AreEqual(1, msg.Keys.Count());
            Assert.AreEqual(new HashSet <string> {
                "a"
            }, new HashSet <string>(msg.Keys));
            Assert.AreEqual(null, msg.DefaultValue);
            Assert.AreEqual("z", msg.GetValue("a"));
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobRunContext"/> class.
        /// </summary>
        public JobRunContext(JobRunInfo jobRunInfoIfo, ForkedExecutionConfiguration configuration, IJobRunProgressChannel progressChannel)
        {
            this.jobRunInfo      = jobRunInfoIfo;
            this.configuration   = configuration;
            this.progressChannel = progressChannel;

            this.serviceMessageParser = new ServiceMessageParser();
        }
        public void parse10000()
        {
            var ps    = new ServiceMessageParser();
            var text  = GenerateTestData(10000);
            var trash = new ArrayList();

            MeasureTime(TimeSpan.FromMilliseconds(1000), 10, () => trash.Add(ps.ParseServiceMessages(text).ToArray()));
            Console.Out.WriteLine(trash);
        }
        public void BrokenStream_H()
        {
            const string text   = @"                 ##teamcity[package Id='CommonServiceLocator' Version='1.0' Authors='Microsoft' Description='The Common Service Locator library contains a shared interface for service location which application and framework developers can reference. The library provides an abstraction over IoC containers and service locators. Using the library allows an application to indirectly access the capabilities without relying on hard references. The hope is that using this library, third-party applications and frameworks can begin to leverage IoC/Service Location without tying themselves down to a specific implementation.' IsLatestVersion='true' LastUpdated='2011-10-21T16:34:09Z' LicenseUrl='http://commonservicelocator.codeplex.com/license' PackageHash='RJjv0yxm+Fk/ak/CVMTGr0ng7g/nudkVYos4eQrIDpth3BdE1j7J2ddRm8FXtOoIZbgDqTU6hKq5zoackwL3HQ==' PackageHashAlgorithm='SHA512' PackageSize='37216' ProjectUrl='http://commonservicelocator.codeplex.com/' RequireLicenseAcceptance='false' TeamCityBuildId='42' TeamCityDownloadUrl='/repository/download/bt/42:id/null']                  ";
            var          bytes  = Encoding.UTF8.GetBytes(text.ToCharArray());
            var          stream = new MemoryStream(bytes);
            var          rdr    = new StreamReader(stream, Encoding.UTF8);
            var          result = new ServiceMessageParser().ParseServiceMessages(rdr).ToArray();

            Assert.IsTrue(result.Length == 1);
        }
Beispiel #5
0
        public void UnknownMessageType_WhenParsed_ReturnsNull()
        {
            var parser = new ServiceMessageParser();

            var raw = "##jobbr[blabla value='57']";

            var message = parser.Parse(raw);

            Assert.IsNull(message);
        }
Beispiel #6
0
        public void MessageWithDoubleValue_WhenParsed_ContainsValue()
        {
            var parser = new ServiceMessageParser();

            var raw = "##jobbr[double value='55.34']";

            var message = (DoubleServiceMessage)parser.Parse(raw);

            Assert.IsNotNull(message);
            Assert.AreEqual(55.34, message.Value);
        }
Beispiel #7
0
        public void MessageWitStringValue_WhenParsed_ContainsValue()
        {
            var parser = new ServiceMessageParser();

            var raw = "##jobbr[string value='hello world']";

            var message = (StringServiceMessage)parser.Parse(raw);

            Assert.IsNotNull(message);
            Assert.AreEqual("hello world", message.Value);
        }
Beispiel #8
0
        public void MessageWitIntValue_WhenParsed_ContainsValue()
        {
            var parser = new ServiceMessageParser();

            var raw = "##jobbr[integer value='57']";

            var message = (IntegerServiceMessage)parser.Parse(raw);

            Assert.IsNotNull(message);
            Assert.AreEqual(57, message.Value);
        }
        public void ShouldParseService_simpleMessage_decode()
        {
            var sr     = new StringWrapper("##teamcity[name '\"|'|n|r|x|l|p||[|]']");
            var result = new ServiceMessageParser().ParseServiceMessages(sr).ToArray();

            Assert.AreEqual(1, result.Length);

            var msg = result[0];

            Assert.AreEqual("name", msg.Name);
            Assert.AreEqual(0, msg.Keys.Count());
            Assert.AreEqual("\"'\n\r\u0085\u2028\u2029|[]", msg.DefaultValue);
        }
        public void ShouldParseService_simpleMessage()
        {
            var sr     = new StringWrapper("##teamcity[name 'a']");
            var result = new ServiceMessageParser().ParseServiceMessages(sr).ToArray();

            Assert.AreEqual(1, result.Length);

            var msg = result[0];

            Assert.AreEqual("name", msg.Name);
            Assert.AreEqual(0, msg.Keys.Count());
            Assert.AreEqual("a", msg.DefaultValue);
        }
Beispiel #11
0
 public ScriptOutputFilter(CalamariInMemoryTaskLog log)
 {
     this.log = log;
     DeltaPackageVerifcation = null;
     DeltaPackageError       = null;
     ResultMessage           = null;
     parser       = new ServiceMessageParser(WritePlainText, ServiceMessage);
     debugTarget  = log.Verbose;
     outputTarget = log.Info;
     errorTarget  = log.Error;
     PopulateSupportedScriptActionNames();
     progressTarget = log.UpdateProgress;
 }
Beispiel #12
0
 public ScriptOutputFilter(ILogWithContext log)
 {
     this.log = log;
     DeltaPackageVerifcation = null;
     DeltaPackageError       = null;
     ResultMessage           = null;
     parser       = new ServiceMessageParser(WritePlainText, ServiceMessage);
     debugTarget  = log.Verbose;
     outputTarget = log.Info;
     errorTarget  = log.Error;
     logContext   = log.CurrentContext;
     PopulateSupportedScriptActionNames();
     progressTarget = log.UpdateProgress;
 }
        public void ShouldParseService_simpleMessages_multi2()
        {
            var sr     = new StringWrapper("##teamcity[name 'a']\r ##teamcity[name 'a']\n ##teamcity[name 'a'] \r\n ##teamcity[name 'a']");
            var result = new ServiceMessageParser().ParseServiceMessages(sr).ToArray();

            Assert.AreEqual(4, result.Length);

            foreach (var msg in result)
            {
                Assert.AreEqual("name", msg.Name);
                Assert.AreEqual(0, msg.Keys.Count());
                Assert.AreEqual("a", msg.DefaultValue);
            }
        }
        public void BrokenStream_Combinatorics()
        {
            var          result = new List <int>();
            const string text   =
                "##teamcity[name 'a'] ##teamcity[name 'a'] ##teamcity[name 'a']  ##teamcity[name 'a'] ##teamcity[name a  =  'a' b='qqq|n'  ]\t##teamcity[name a='z']\r\n##teamcity[name a='z']\r##teamcity[name a='z']##teamcity[package Id='CommonServiceLocator' Version='1.0' Authors='Microsoft' Description='The Common Service Locator library contains a shared interface for service location which application and framework developers can reference. The library provides an abstraction over IoC containers and service locators. Using the library allows an application to indirectly access the capabilities without relying on hard references. The hope is that using this library, third-party applications and frameworks can begin to leverage IoC/Service Location without tying themselves down to a specific implementation.' IsLatestVersion='true' LastUpdated='2011-10-21T16:34:09Z' LicenseUrl='http://commonservicelocator.codeplex.com/license' PackageHash='RJjv0yxm+Fk/ak/CVMTGr0ng7g/nudkVYos4eQrIDpth3BdE1j7J2ddRm8FXtOoIZbgDqTU6hKq5zoackwL3HQ==' PackageHashAlgorithm='SHA512' PackageSize='37216' ProjectUrl='http://commonservicelocator.codeplex.com/' RequireLicenseAcceptance='false' TeamCityBuildId='42' TeamCityDownloadUrl='/repository/download/bt/42:id/null']";

            for (int i = 0; i < text.Length; i++)
            {
                for (int j = i; j < text.Length; j++)
                {
                    string input = text.Substring(i, text.Length - j);
                    var    count = new ServiceMessageParser().ParseServiceMessages(input).ToArray().Length;
                    result.Add(count);
                }
            }
            Assert.IsTrue(result.Contains(9));
        }
        public void ShouldParseString()
        {
            var result = new ServiceMessageParser().ParseServiceMessages("##teamcity[name    a='1\"|'|n|r|x|l|p||[|]'     b='2\"|'|n|r|x|l|p||[|]'   ]").ToArray();

            Assert.AreEqual(1, result.Length);

            var msg = result[0];

            Assert.AreEqual("name", msg.Name);
            Assert.AreEqual(2, msg.Keys.Count());
            Assert.AreEqual(new HashSet <string> {
                "a", "b"
            }, new HashSet <string>(msg.Keys));
            Assert.AreEqual(null, msg.DefaultValue);
            Assert.AreEqual("1\"'\n\r\u0085\u2028\u2029|[]", msg.GetValue("a"));
            Assert.AreEqual("2\"'\n\r\u0085\u2028\u2029|[]", msg.GetValue("b"));
        }
        public void ShouldParseService_complexMessage2()
        {
            var sr     = new StringWrapper("##teamcity[name    a='a'     b='z'   ]");
            var result = new ServiceMessageParser().ParseServiceMessages(sr).ToArray();

            Assert.AreEqual(1, result.Length);

            var msg = result[0];

            Assert.AreEqual("name", msg.Name);
            Assert.AreEqual(2, msg.Keys.Count());
            Assert.AreEqual(new HashSet <string> {
                "a", "b"
            }, new HashSet <string>(msg.Keys));
            Assert.AreEqual(null, msg.DefaultValue);
            Assert.AreEqual("a", msg.GetValue("a"));
            Assert.AreEqual("z", msg.GetValue("b"));
        }
        public void ShouldParseService_complexMessage_multi()
        {
            var sr     = new StringWrapper("  ##teamcity[name a='z']##teamcity[name a='z']##teamcity[name a='z']  ");
            var result = new ServiceMessageParser().ParseServiceMessages(sr).ToArray();

            Assert.AreEqual(3, result.Length);

            foreach (var msg in result)
            {
                Assert.AreEqual("name", msg.Name);
                Assert.AreEqual(1, msg.Keys.Count());
                Assert.AreEqual(new HashSet <string> {
                    "a"
                }, new HashSet <string>(msg.Keys));
                Assert.AreEqual(null, msg.DefaultValue);
                Assert.AreEqual("z", msg.GetValue("a"));
            }
        }
Beispiel #18
0
 public CaptureCommandOutput()
 {
     serviceMessageParser = new ServiceMessageParser(ParseServiceMessage);
 }
 public void SetUp()
 {
     messages = new List <ServiceMessage>();
     parser   = new ServiceMessageParser((message) => messages.Add(message));
 }
Beispiel #20
0
 public CaptureCommandInvocationOutputSink()
 {
     serviceMessageParser = new ServiceMessageParser(ParseServiceMessage);
 }