Exemplo n.º 1
0
        public void ChangeType_ReturnsNullIfTypeAllowsNulls()
        {
            // Act
            var actual = CommandLineUtility.ChangeType(null, typeof(int?));

            // Assert
            Assert.IsNull(actual);
        }
Exemplo n.º 2
0
        public void ChangeType_ReturnsConvertedTypeWhenThereIsAConverterFromTheType()
        {
            // Act
            var actual = CommandLineUtility.ChangeType("3", typeof(int));

            // Assert
            Assert.AreEqual(typeof(int), actual.GetType());
            Assert.AreEqual(3, actual);
        }
Exemplo n.º 3
0
        public void ChangeType_ReturnsValueIfTypesMatch()
        {
            // Act
            var actual = CommandLineUtility.ChangeType(3, typeof(int));

            // Assert
            Assert.AreEqual(typeof(int), actual.GetType());
            Assert.AreEqual(3, actual);
        }
Exemplo n.º 4
0
 public void ChangeType_ThrowsIfTypeDoesNotAllowNulls()
 {
     // Act & Assert
     ExceptionAssert.Throws <InvalidCastException>(() => CommandLineUtility.ChangeType(null, typeof(int)));
 }
Exemplo n.º 5
0
 public void ChangeType_ThrowsIfTypeIsNull()
 {
     // Act & Assert
     ExceptionAssert.ThrowsArgNull(() => CommandLineUtility.ChangeType(new object(), null), "type");
 }
Exemplo n.º 6
0
 public void ChangeType_ThrowWhenThereIsNoConverterForEither()
 {
     // Act & Assert
     ExceptionAssert.Throws <InvalidOperationException>(() => CommandLineUtility.ChangeType(false, typeof(MockClass)));
 }