Exemplo n.º 1
0
            public void TestKeyOnlyParse()
            {
                // Given
                var excepted = new string[] { "hi", "=hello", "\\=abcd", "key\\=val", "     bjorn  \\=   dad" };

                // When
                var args = GlobalMetadataParser.Parse(excepted);

                // Then
                Assert.AreEqual(excepted.Length, args.Count);
                int i = 0;

                foreach (var arg in args)
                {
                    Assert.AreEqual(excepted[i].Replace("\\=", "=").Trim(), arg.Key);
                    Assert.IsNull(arg.Value);
                    i++;
                }
            }
Exemplo n.º 2
0
            public void TestKeyValueParse()
            {
                // Given
                var pairs = new string[]
                { "key=value", "k=v", "except=bro", "awesome====123123", "   keytrimmed    =    value trimmed   " };

                // When
                var args = GlobalMetadataParser.Parse(pairs);

                // Then
                Assert.AreEqual(pairs.Length, args.Count);
                foreach (var arg in args)
                {
                    Assert.NotNull(arg.Value, "Argument value should not be null.");
                    StringAssert.DoesNotStartWith(" ", arg.Key, "Arguments key should be trimmed.");
                    StringAssert.DoesNotEndWith(" ", arg.Key, "Arguments key should be trimmed.");
                    StringAssert.DoesNotStartWith(" ", (string)arg.Value, "Arguments value should be trimmed.");
                    StringAssert.DoesNotEndWith(" ", (string)arg.Value, "Arguments value should be trimmed.");
                }
            }
Exemplo n.º 3
0
 public void SetUp()
 {
     _parser = new GlobalMetadataParser();
 }
Exemplo n.º 4
0
 public void TestMetadataKeyCollision()
 {
     // Given, When, Then
     Assert.Throws <MetadataParseException>(
         () => GlobalMetadataParser.Parse(new string[] { "hello=world", "hello=exception" }));
 }