public void ConvertThrowsExceptionIfNoPublicConstructor() { var test = new StringFormatTest("3"); var ex = Assert.Throws <InvalidOperationException>(() => Format.Convert(typeof(StringFormatTest), test, typeof(ulong))); Assert.AreEqual( "The converter has no constructor without arguments.\n" + "Create the converter object and use ConvertWith<T>.", ex.Message); }
public void ConvertThrowsExceptionIfTwoConverters() { var test = new StringFormatTest("3"); var ex = Assert.Throws <InvalidOperationException>(() => Format.Convert(typeof(StringFormatTest), test, typeof(short))); Assert.AreEqual( "No single converter for " + "Libgame.UnitTests.FileFormat.StringFormatTest -> System.Int16", ex.Message); }
public void ConvertWithThrowsExceptionIfInvalidConverter() { var format = new StringFormatTest("3"); var converter = new StringFormatTest2IntFormatTestConverter(); var ex = Assert.Throws <ArgumentException>(() => Format.ConvertWith(format, typeof(short), converter)); Assert.AreEqual( "Converter cannot convert from/to the type" + Environment.NewLine + "Parameter name: converter", ex.Message); }
public void ConvertWithThrowsExceptionIfNoImplementIConverter() { var format = new StringFormatTest("3"); double converter = 0; var ex = Assert.Throws <ArgumentException>(() => Format.ConvertWith(format, typeof(short), converter)); Assert.AreEqual( "Converter doesn't implement IConverter<,>" + Environment.NewLine + "Parameter name: converter", ex.Message); }
public void ClassConvertTo() { var format = new StringFormatTest("3"); Assert.AreEqual(format.ConvertTo(typeof(int)), 3); }
public void ClassConvertToGeneric() { var format = new StringFormatTest("3"); Assert.AreEqual(format.ConvertTo <int>(), 3); }