public void GetProductValue_InvalidArabicNumeralContent(string content)
        {
            this.ruleValidator.Setup(i => i.Validate(It.IsAny <int>()))
            .Returns("Error")
            .Verifiable();

            this.ruleValidator.Setup(i => i.Validate(It.IsAny <string>()))
            .Returns("Error")
            .Verifiable();

            this.validator = new ProductDataValidator(this.ruleValidator.Object,
                                                      this.productCategorizer.Object,
                                                      new string[] { });

            var result = this.validator.GetProductValue(content, 1);

            Assert.IsEmpty(result);

            int index = content.IndexOf(CREDITS_TEXT, StringComparison.OrdinalIgnoreCase);

            if (index < 1) // -1 for string, 0 if Credits is the first word in the split.
            {
                this.ruleValidator.Verify(i => i.Validate(It.IsAny <string>()), Times.AtLeastOnce);
            }
            else
            {
                this.ruleValidator.Verify(i => i.Validate(It.IsAny <int>()), Times.AtLeastOnce);
            }
        }
        public void GetProducts_NullOrEmptyOrWhitespaceContent(string content)
        {
            this.validator = new ProductDataValidator(this.ruleValidator.Object,
                                                      this.productCategorizer.Object,
                                                      new string[] { });

            var results = validator.GetProducts(content, 1);

            Assert.IsNull(results);
        }
        public void GetProductValue_RomanNumeralContentWithoutCredits(string content)
        {
            this.ruleValidator.Setup(i => i.Validate(It.IsAny <string>()))
            .Returns(string.Empty)
            .Verifiable();

            this.validator = new ProductDataValidator(this.ruleValidator.Object,
                                                      this.productCategorizer.Object,
                                                      new string[] { });

            var result = this.validator.GetProductValue(content, 1);

            Assert.IsNotEmpty(result);
            Assert.AreEqual(content, result);
        }
        public void GetProducts_InvalidProductType()
        {
            this.productCategorizer.Setup(i => i.IsProductValid(It.IsAny <string>()))
            .Returns(false)
            .Verifiable();

            this.validator = new ProductDataValidator(this.ruleValidator.Object,
                                                      this.productCategorizer.Object,
                                                      new string[] { });

            string content = "kryptonite gummyl Diamond";

            var results = validator.GetProducts(content, 1);

            Assert.IsNull(results);
            this.productCategorizer.Verify(i => i.IsProductValid(It.IsAny <string>()), Times.AtLeastOnce);
        }
        public void GetProductValue_ValidArabicNumeralContent(string content)
        {
            this.ruleValidator.Setup(i => i.Validate(It.IsAny <int>()))
            .Returns(string.Empty)
            .Verifiable();

            this.validator = new ProductDataValidator(this.ruleValidator.Object,
                                                      this.productCategorizer.Object,
                                                      new string[] { });

            var result = this.validator.GetProductValue(content, 1);

            Assert.IsNotEmpty(result);

            int    number       = 0;
            string numberString = content.Substring(0, content.IndexOf(CREDITS_TEXT, StringComparison.OrdinalIgnoreCase) - 1).Trim();

            int.TryParse(numberString, out number);

            Assert.AreEqual(numberString.ToString(), result);
        }