private object[] GetArgs() { return(new object[] { 0, 1, 2, 3, -1, -2, // {4},{5} TestFactory.GetPerson(), // {6} false, true, // {7},{8} new DateTime(1111, 1, 1, 1, 1, 1), DateTime.Now, new DateTime(5555, 5, 5, 5, 5, 5), // {9},{10},{11} new TimeSpan(-1, -1, -1, -1, -1), TimeSpan.Zero, new TimeSpan(5, 5, 5, 5, 5), // {12},{13},{14} "Hello", "", // {15},{16} new { NotNull = true }, null, // {17},{18} }); }
public void Parser_Throws_Exceptions() { // Let's set the "ErrorAction" to "Throw": var formatter = Smart.CreateDefaultSmartFormat(); formatter.Parser.ErrorAction = ErrorAction.ThrowError; var args = new object[] { TestFactory.GetPerson() }; var invalidFormats = new[] { "{", "{0", "}", "0}", "{{{", "}}}", "{.}", "{.:}", "{..}", "{..:}", "{0.}", "{0.:}", }; foreach (var format in invalidFormats) { try { formatter.Test(format, args, "Error"); // Make sure that EVERY item has an error: Assert.Fail("Parsing \"{0}\" should have failed but did not.", format); } catch (ParsingErrors ex) { } } }