Inheritance: System.ComponentModel.TypeConverter
Ejemplo n.º 1
0
        public void ConvertFrom_Requires_NonNull_Input()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act and Assert
            AutoTester.ArgumentNull<object>(m => converter.ConvertFrom(m));
        }
Ejemplo n.º 2
0
        public void ConvertFrom_Throws_ArgumentException_If_String_Has_Fewer_Than_Two_Version_Components()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act and Assert
            ExceptionAssert.Throws<ArgumentException>(() => converter.ConvertFrom(TestTooShortVersion));
        }
Ejemplo n.º 3
0
        public void ConvertFrom_Successfully_Converts_String_To_Version()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act
            Version converted = (Version)converter.ConvertFrom(TestVersionString);

            // Assert
            Assert.AreEqual(TestMajor, converted.Major);
            Assert.AreEqual(TestMinor, converted.Minor);
            Assert.AreEqual(TestBuild, converted.Build);
            Assert.AreEqual(TestRevision, converted.Revision);
        }
Ejemplo n.º 4
0
        public void ConvertFrom_Throws_ArgumentOutOfRangeException_If_Build_Is_Negative()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act and Assert
            ExceptionAssert.Throws<ArgumentOutOfRangeException>(() => converter.ConvertFrom(TestBuildNegativeVersion));
        }
Ejemplo n.º 5
0
        public void ConvertTo_Throws_NotSupportedException_If_Target_Type_Is_Not_String()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act and Assert
            ExceptionAssert.Throws<NotSupportedException>(() => converter.ConvertTo(TestVersion, typeof(DateTime)));
        }
Ejemplo n.º 6
0
        public void ConvertTo_Returns_Version_String_If_Target_Type_Is_String()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act
            string result = (string)converter.ConvertTo(TestVersion,
                                                        typeof(string));

            // Assert
            Assert.AreEqual(TestVersionString, result);
        }
Ejemplo n.º 7
0
        public void ConvertTo_Requires_NonNull_Input()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act and Assert
            AutoTester.ArgumentNull<object>(m => converter.ConvertTo(m, typeof(string)));
        }
Ejemplo n.º 8
0
        public void ConvertFrom_Throws_OverflowException_If_Version_Component_Too_Big()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act and Assert
            ExceptionAssert.Throws<OverflowException>(() => converter.ConvertFrom(TestLargeComponentVersion));
        }
Ejemplo n.º 9
0
        public void ConvertFrom_Throws_NotSupportedException_On_Non_String_Input()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();
            object toConvert = new object();

            // Act and Assert
            ExceptionAssert.Throws<NotSupportedException>(() => converter.ConvertFrom(toConvert));
        }
Ejemplo n.º 10
0
        public void ConvertFrom_Throws_FormatException_If_Version_Is_Not_Integer()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act and Assert
            ExceptionAssert.Throws<FormatException>(() => converter.ConvertFrom(TestNonIntegerVersion));
        }