Esempio n. 1
0
        public void CanConvertFromShouldReturnFalseWhenSourceTypeIsUnsupported()
        {
            // Note, this is default TypeConverter behavior
            var converter = new StampConverter();

            converter.CanConvertFrom(typeof(int)).Should().BeFalse();
        }
Esempio n. 2
0
        public void ConvertFromShouldParseString()
        {
            var   converter = new StampConverter();
            Stamp result    = (Stamp)converter.ConvertFrom("(((1,0),0),(0,(1,1,0),0))");

            result.Should().Be(new Stamp(((1, 0), 0), (0, (1, 1, 0), 0)));
        }
Esempio n. 3
0
        public void CanConvertToShouldReturnFalseWhenDestinationTypeIsUnsupported()
        {
            // Note, this is default TypeConverter behavior
            var converter = new StampConverter();

            converter.CanConvertTo(typeof(int)).Should().BeFalse();
        }
Esempio n. 4
0
        public void CanConvertToShouldReturnTrueWhenDestinationTypeIsString()
        {
            // Note, this is default TypeConverter behavior
            var converter = new StampConverter();

            converter.CanConvertTo(typeof(string)).Should().BeTrue();
        }
Esempio n. 5
0
        public void IsValidShouldReturnTrueForLegitimateStampString()
        {
            // Note, this is default TypeConverter behavior
            var  converter = new StampConverter();
            bool result    = converter.IsValid("(((1,0),0),(0,(1,1,0),0))");

            result.Should().BeTrue();
        }
Esempio n. 6
0
        public void IsValidShouldReturnFalseForMalformedStampString()
        {
            // Note, this is default TypeConverter behavior
            var  converter = new StampConverter();
            bool result    = converter.IsValid("(((1,0),0),(0,(1,1,0);0))");

            //                                                    ^--- invalid char

            result.Should().BeFalse();
        }
Esempio n. 7
0
        public void ConvertToShouldThrowWhenDestinationTypeIsUnsupported()
        {
            // Note, this is default TypeConverter behavior
            Stamp stamp     = new Stamp(((1, 0), 0), (0, (1, 1, 0), 0));
            var   converter = new StampConverter();

            Action act = () => converter.ConvertTo(stamp, typeof(int));

            act.ShouldThrow <NotSupportedException>();
        }
Esempio n. 8
0
        public void ConvertToShouldEqualStampStringRepresentationWhenDestinationTypeIsString()
        {
            // Note, this is default TypeConverter behavior (will call value.ToString method)
            Stamp stamp     = new Stamp(((1, 0), 0), (0, (1, 1, 0), 0));
            var   converter = new StampConverter();

            string result = (string)converter.ConvertTo(stamp, typeof(string));

            result.Should().Be(stamp.ToString());
            result.Should().Be("(((1,0),0),(0,(1,1,0),0))");
        }
Esempio n. 9
0
        public void CanConvertFromShouldReturnTrueWhenSourceTypeIsString()
        {
            var converter = new StampConverter();

            converter.CanConvertFrom(typeof(string)).Should().BeTrue();
        }