Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public void ClassConvertTo()
        {
            var format = new StringFormatTest("3");

            Assert.AreEqual(format.ConvertTo(typeof(int)), 3);
        }
Esempio n. 6
0
        public void ClassConvertToGeneric()
        {
            var format = new StringFormatTest("3");

            Assert.AreEqual(format.ConvertTo <int>(), 3);
        }