Ejemplo n.º 1
0
        public void ValueCastDouble_ValueIsInt_DoesNotThrow()
        {
            // Arrange
            var mock = new Mock <QuantityBase>();

            mock.Setup(x => x.QuantityValueType).Returns(typeof(int));
            mock.Setup(x => x.QuantityValue).Returns(1);
            QuantityBase quantity = mock.Object;

            // Act/assert
            Assert.DoesNotThrow(() => quantity.ValueCast <double>());
        }
Ejemplo n.º 2
0
        public void ValueCastNotRelated_ValueIsInt_ThrowsInvalidCast()
        {
            // Arrange
            var mock = new Mock <QuantityBase>();

            mock.Setup(x => x.QuantityValueType).Returns(typeof(int));
            mock.Setup(x => x.QuantityValue).Returns(1);
            QuantityBase quantity = mock.Object;


            // Act/assert
            Assert.Throws <InvalidCastException>(() => quantity.ValueCast <Array>());
        }