Наследование: System.ComponentModel.TypeConverter
Пример #1
0
        public void ConvertFrom_Requires_NonNull_Input()
        {
            // Arrange
            VersionConverter converter = new VersionConverter();

            // Act and Assert
            AutoTester.ArgumentNull<object>(m => converter.ConvertFrom(m));
        }
Пример #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));
        }
Пример #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);
        }
Пример #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));
        }
Пример #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)));
        }
Пример #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);
        }
Пример #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)));
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
        }