Advertisement
Guest User

Untitled

a guest
May 20th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. [TestMethod]
  2. public void ParseIntValues()
  3. {
  4. ITemplateBuilder templateBuilder = new TemplateBuilder();
  5. var template = templateBuilder.CreateTemplate(
  6. r => r.UseStrictMode()
  7. .AddSection(s => s.WithName("myIntSection")
  8. .AddOption(o => o.WithName("Ints1")
  9. .SetValue(v => v.SetInt()))
  10. .AddOption(o => o.WithName("Ints2")
  11. .SetValue(v => v.SetInt()))
  12. )
  13. );
  14.  
  15. string configuration = "[myIntSection]"
  16. + Environment.NewLine + "Ints1=1,2,3,4"
  17. + Environment.NewLine + "Ints2=5, 6, 4899";
  18. var parser = new DocumentParser(new TokenParser());
  19. var document = parser.Parse(new StringReader(configuration), template);
  20. Assert.AreEqual(2, document["myIntSection"].OptionsCount);
  21.  
  22. Assert.IsInstanceOfType(document["myIntSection"]["Ints1"], typeof(IntOption));
  23. IntOption io = (IntOption)document["myIntSection"]["Ints1"];
  24. Assert.AreEqual("Ints", io.Identifier);
  25. Assert.AreEqual(1, io[0]);
  26. Assert.AreEqual(2, io[1]);
  27. Assert.AreEqual(3, io[2]);
  28. Assert.AreEqual(489, io[3]);
  29.  
  30. Assert.IsInstanceOfType(document["myIntSection"]["Ints2"], typeof(IntOption));
  31. IntOption io2 = (IntOption)document["myIntSection"]["Ints2"];
  32. Assert.AreEqual(5, io2[0]);
  33. Assert.AreEqual(6, io2[1]);
  34. Assert.AreEqual(4899, io2[2]);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement