public void Validate_ValueIsNotString_ReturnInvalid()
        {
            // Setup
            var validationRule = new NumberOfDiceRule();

            // Call
            ValidationResult result = validationRule.Validate(new object(), CultureInfo.CurrentCulture);

            // Assert
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual("Number of dice must be specified.", result.ErrorContent);
        }
        public void Validate_NumberOfDieSidesNotIntegerString_ReturnInvalid()
        {
            // Setup
            var validationRule = new NumberOfDiceRule();

            // Call
            ValidationResult result = validationRule.Validate("A", CultureInfo.CurrentCulture);

            // Assert
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual("Number of dice must be a whole number.", result.ErrorContent);
        }
        public void Validate_ValueNullOrWhitespace_ReturnInvalid(string invalidValue)
        {
            // Setup
            var validationRule = new NumberOfDiceRule();

            // Call
            ValidationResult result = validationRule.Validate(invalidValue, CultureInfo.CurrentCulture);

            // Assert
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual("Number of dice must be specified.", result.ErrorContent);
        }
        public void Constructor_ExpectedValues()
        {
            // Call
            var validationRule = new NumberOfDiceRule();

            // Assert
            Assert.IsInstanceOf <IntegerParsingRule>(validationRule);

            Assert.AreEqual("Number of dice", validationRule.ParameterName);

            Assert.IsFalse(validationRule.ValidatesOnTargetUpdated);
            Assert.AreEqual(ValidationStep.RawProposedValue, validationRule.ValidationStep);
        }
        public void Validate_InvalidNumberOfDieSides_ReturnInvalid(int invalidNumberOfSides)
        {
            // Setup
            var validationRule = new NumberOfDiceRule();

            var cultureInfo = CultureInfo.CurrentCulture;

            // Call
            ValidationResult result = validationRule.Validate(invalidNumberOfSides.ToString(cultureInfo), cultureInfo);

            // Assert
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual("Number of dice must be greater than zero.", result.ErrorContent);
        }
        public void Validate_ValidNumberOfDieSides_ReturnValidResult(int value)
        {
            // Setup
            var validationRule = new NumberOfDiceRule();

            CultureInfo cultureInfo = CultureInfo.CurrentCulture;

            // Call
            ValidationResult result = validationRule.Validate(value.ToString(cultureInfo), cultureInfo);

            // Assert
            Assert.IsTrue(result.IsValid);
            Assert.IsNull(result.ErrorContent);
        }
        public void Validate_NumberOfDieSidesTooLarge_ReturnInvalid(int extremeValue)
        {
            // Setup
            var validationRule = new NumberOfDiceRule();

            CultureInfo cultureInfo      = CultureInfo.CurrentCulture;
            string      overflowingValue = extremeValue.ToString(cultureInfo) + "1";

            // Call
            ValidationResult result = validationRule.Validate(overflowingValue, cultureInfo);

            // Assert
            Assert.IsFalse(result.IsValid);
            Assert.AreEqual("Number of dice is too large or too small.", result.ErrorContent);
        }