Ejemplo n.º 1
0
        public void Convert_To_When_Called_Several_Ways_Returns_Expected_Results()
        {
            string testString = "123";
            int    testResult = 123;

            // Happy Path (_converter.Convert.To)
            Assert.That(_converter.Convert(testString).To <int>(), Is.TypeOf <int>().And.EqualTo(testResult));

            // Sad Path (stored converter no long just returns default when not provided a string; string is stored internally)
            IStringConverter newConverter = _converter.Convert(testString);

            Assert.That(_converter.To <int>(), Is.TypeOf <int>().And.EqualTo(default(int)));
            Assert.That(newConverter.To <int>(), Is.TypeOf <int>().And.EqualTo(testResult));
        }
Ejemplo n.º 2
0
 public void To_Should_Return_Default_Of_Type()
 {
     Assert.That(_converter.To <bool>(), Is.EqualTo(default(bool)));
     Assert.That(_converter.To <char>(), Is.EqualTo(default(char)));
     Assert.That(_converter.To <string>(), Is.EqualTo(default(string)));
     Assert.That(_converter.To <byte>(), Is.EqualTo(default(byte)));
     Assert.That(_converter.To <sbyte>(), Is.EqualTo(default(sbyte)));
     Assert.That(_converter.To <decimal>(), Is.EqualTo(default(decimal)));
     Assert.That(_converter.To <double>(), Is.EqualTo(default(double)));
     Assert.That(_converter.To <float>(), Is.EqualTo(default(float)));
     Assert.That(_converter.To <int>(), Is.EqualTo(default(int)));
     Assert.That(_converter.To <uint>(), Is.EqualTo(default(uint)));
     Assert.That(_converter.To <long>(), Is.EqualTo(default(long)));
     Assert.That(_converter.To <ulong>(), Is.EqualTo(default(ulong)));
     Assert.That(_converter.To <short>(), Is.EqualTo(default(short)));
     Assert.That(_converter.To <ushort>(), Is.EqualTo(default(ushort)));
 }