public void CreateReference_Failing(ArgumentConstructor type, string config, IEnumerable <string> argument, IEnumerable <ArgumentSchema> schema, ErrorCode error, string argumentId, string parameter, string message) { Exception a = CreateConstructor_Failing(type, config, argument, schema); if (a is BaseArgumentException) { BaseArgumentException ex = a as BaseArgumentException; Assert.Equal(error, ex.ErrorCode); if (!string.IsNullOrEmpty(argumentId)) { Assert.Equal(argumentId, ex.ErrorArgumentId); } else { Assert.Null(ex.ErrorArgumentId); } Assert.Equal(parameter, ex.ErrorParameter); if (!string.IsNullOrEmpty(message)) { Assert.Equal(message, ex.ErrorMessage()); } else { Assert.Equal(parameter, ex.ErrorMessage()); } } else { throw new XunitException(); } }
public void CreateReferenceWithWrongDelimiterAndGetValues_Failing(ArgumentConstructor type, string config, string[] arguments) { Argument a = CreateConstructor_Passing(type, config, arguments, schema); ArgumentException ex = Assert.Throws <ArgumentException>(() => a.GetValue <object>(arguments[1].Substring(2).ToString()).ToString()); Assert.Equal(ErrorCode.INVALID_PARAMETER, ex.ErrorCode); Assert.Null(ex.ErrorArgumentId); Assert.Equal(arguments[1].Substring(2).ToString(), ex.ErrorParameter); Assert.Equal($"'{arguments[1].Substring(2).ToString()}' is not a valid parameter", ex.ErrorMessage()); }
public void CreateReferenceAndGetArgumentsFound_Passing(ArgumentConstructor type, string config, string[] arguments, int length) { Argument a = CreateConstructor_Passing(type, config, arguments, schema); List <string> argumentList = new List <string>(); for (int i = 0; i < length; i += 2) { argumentList.Add(arguments.ElementAt(i).Substring(1).ToLower()); } for (int i = length; i < arguments.Length; i++) { argumentList.Add(arguments.ElementAt(i).Substring(1).ToLower()); } Assert.True(argumentList.SequenceEqual(a.ArgumentsFound)); }
private Argument CreateConstructor_Passing(ArgumentConstructor type, string path, IEnumerable <string> argument, IEnumerable <ArgumentSchema> schema) { Argument a; switch (type) { case ArgumentConstructor.WithSchema: a = new Argument(path, argument, schema); break; case ArgumentConstructor.WithoutSchema: a = new Argument(path, argument); break; default: throw new XunitException("TILT: should not be reached!"); } return(a); }
public void CreateReferenceAndGetRequiredValue_Failing(ArgumentConstructor type, string config, string[] arguments) { Argument arg = CreateConstructor_Passing(type, config, arguments.Skip(2).Take(2), schema.Take(4)); Exception a = Assert.Throws <ArgumentException>(() => arg.GetValue <string>(arguments[0].Substring(1).ToString())); if (a is BaseArgumentException) { BaseArgumentException ex = a as BaseArgumentException; Assert.Equal(ErrorCode.MISSING, ex.ErrorCode); Assert.Equal("string, text, data", ex.ErrorArgumentId); Assert.Null(ex.ErrorParameter); Assert.Equal("Missing parameter: ('string, text, data')", ex.ErrorMessage()); } else { throw new XunitException(); } }
private Exception CreateConstructor_Failing(ArgumentConstructor type, string path, IEnumerable <string> argument, IEnumerable <ArgumentSchema> schema) { Argument a; Exception ex; switch (type) { case ArgumentConstructor.WithSchema: ex = Record.Exception(() => a = new Argument(path, argument, schema)); break; case ArgumentConstructor.WithoutSchema: ex = Record.Exception(() => a = new Argument(path, argument)); break; default: throw new XunitException("TILT: should not be reached!"); } return(ex); }
public void CreateReferenceAndGetValue_Passing(ArgumentConstructor type, string config, string[] arguments, int length) { Argument a = CreateConstructor_Passing(type, config, arguments, schema); string text = arguments[0].Substring(1).ToString(); for (int i = 0; i < (length - 1); i += 2) { Assert.Equal(arguments[(i + 1)], a.GetValue <object>(arguments[i].Substring(1).ToString()).ToString()); } Random r = new Random(); if ((arguments.Length - length) % 2 == 0) { Assert.True(a.GetValue <bool>(booleanArgs[0].Split(",")[r.Next(0, 1)].Substring(1).ToString())); Assert.True(a.GetValue <bool>(booleanArgs[1].Split(",")[r.Next(0, 1)].Substring(1).ToString())); } else { Assert.True(a.GetValue <bool>(booleanArgs[0].Split(",")[r.Next(0, 1)].Substring(1).ToString())); Assert.False(a.GetValue <bool>(booleanArgs[1].Split(",")[r.Next(0, 1)].Substring(1).ToString())); } }
public void CreateReference_Passing(ArgumentConstructor type, string config, string[] arguments) { Argument a = CreateConstructor_Passing(type, config, arguments, schema); }