public object[] GetArgs() { return(new object[] { "Zero", 111, new DateTime(2222, 2, 2, 2, 2, 2), new { Value = 3, Anon = true }, TestFactory.GetPerson(), }); }
public object[] GetArgs() { var args = new object[] { "ABCDE".ToCharArray(), "One|Two|Three|Four|Five".Split('|'), TestFactory.GetPerson().Friends, "1/1/2000|10/10/2010|5/5/5555".Split('|').Select(s => DateTime.ParseExact(s, "M/d/yyyy", null)), new [] { 1, 2, 3, 4, 5 }, }; return(args); }
public object[] GetArgs() { var args = new object[] { "ABCDE".ToCharArray(), "One|Two|Three|Four|Five".Split('|'), TestFactory.GetPerson().Friends, "1/1/2000|10/10/2010|5/5/5555".Split('|').Select(s => DateTime.ParseExact(s, "M/d/yyyy", System.Globalization.CultureInfo.CreateSpecificCulture("en-us"))), new [] { 1, 2, 3, 4, 5 }, }; return(args); }
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) { } } }