Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [TestMethod]
- public void ParseIntValues()
- {
- ITemplateBuilder templateBuilder = new TemplateBuilder();
- var template = templateBuilder.CreateTemplate(
- r => r.UseStrictMode()
- .AddSection(s => s.WithName("myIntSection")
- .AddOption(o => o.WithName("Ints1")
- .SetValue(v => v.SetInt()))
- .AddOption(o => o.WithName("Ints2")
- .SetValue(v => v.SetInt()))
- )
- );
- string configuration = "[myIntSection]"
- + Environment.NewLine + "Ints1=1,2,3,4"
- + Environment.NewLine + "Ints2=5, 6, 4899";
- var parser = new DocumentParser(new TokenParser());
- var document = parser.Parse(new StringReader(configuration), template);
- Assert.AreEqual(2, document["myIntSection"].OptionsCount);
- Assert.IsInstanceOfType(document["myIntSection"]["Ints1"], typeof(IntOption));
- IntOption io = (IntOption)document["myIntSection"]["Ints1"];
- Assert.AreEqual("Ints", io.Identifier);
- Assert.AreEqual(1, io[0]);
- Assert.AreEqual(2, io[1]);
- Assert.AreEqual(3, io[2]);
- Assert.AreEqual(489, io[3]);
- Assert.IsInstanceOfType(document["myIntSection"]["Ints2"], typeof(IntOption));
- IntOption io2 = (IntOption)document["myIntSection"]["Ints2"];
- Assert.AreEqual(5, io2[0]);
- Assert.AreEqual(6, io2[1]);
- Assert.AreEqual(4899, io2[2]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement