public static void Format_Invalid()
{
var formatter = new TestFormatter();
var obj1 = new object();
var obj2 = new object();
var obj3 = new object();
var obj4 = new object();
// Format is null
Assert.Throws<ArgumentNullException>("format", () => string.Format(null, obj1));
Assert.Throws<ArgumentNullException>("format", () => string.Format(null, obj1, obj2));
Assert.Throws<ArgumentNullException>("format", () => string.Format(null, obj1, obj2, obj3));
Assert.Throws<ArgumentNullException>("format", () => string.Format(null, obj1, obj2, obj3, obj4));
Assert.Throws<ArgumentNullException>("format", () => string.Format(formatter, null, obj1));
Assert.Throws<ArgumentNullException>("format", () => string.Format(formatter, null, obj1, obj2));
Assert.Throws<ArgumentNullException>("format", () => string.Format(formatter, null, obj1, obj2, obj3));
// Args is null
Assert.Throws<ArgumentNullException>("args", () => string.Format("", null));
Assert.Throws<ArgumentNullException>("args", () => string.Format(formatter, "", null));
// Args and format are null
Assert.Throws<ArgumentNullException>("format", () => string.Format(null, (object[])null));
Assert.Throws<ArgumentNullException>("format", () => string.Format(formatter, null, null));
// Format has value < 0
Assert.Throws<FormatException>(() => string.Format("{-1}", obj1));
Assert.Throws<FormatException>(() => string.Format("{-1}", obj1, obj2));
Assert.Throws<FormatException>(() => string.Format("{-1}", obj1, obj2, obj3));
Assert.Throws<FormatException>(() => string.Format("{-1}", obj1, obj2, obj3, obj4));
Assert.Throws<FormatException>(() => string.Format(formatter, "{-1}", obj1));
Assert.Throws<FormatException>(() => string.Format(formatter, "{-1}", obj1, obj2));
Assert.Throws<FormatException>(() => string.Format(formatter, "{-1}", obj1, obj2, obj3));
Assert.Throws<FormatException>(() => string.Format(formatter, "{-1}", obj1, obj2, obj3, obj4));
// Format has out of range value
Assert.Throws<FormatException>(() => string.Format("{1}", obj1));
Assert.Throws<FormatException>(() => string.Format("{2}", obj1, obj2));
Assert.Throws<FormatException>(() => string.Format("{3}", obj1, obj2, obj3));
Assert.Throws<FormatException>(() => string.Format("{4}", obj1, obj2, obj3, obj4));
Assert.Throws<FormatException>(() => string.Format(formatter, "{1}", obj1));
Assert.Throws<FormatException>(() => string.Format(formatter, "{2}", obj1, obj2));
Assert.Throws<FormatException>(() => string.Format(formatter, "{3}", obj1, obj2, obj3));
Assert.Throws<FormatException>(() => string.Format(formatter, "{4}", obj1, obj2, obj3, obj4));
}