コード例 #1
0
        public void GetProducts_ValidProductNotInCache()
        {
            ICollection <string> productsList = new Collection <string> {
                "glob", "drd"
            };
            int cacheCount = productsList.Count();

            this.productCategorizer.Setup(i => i.IsProductValid(It.IsAny <string>()))
            .Returns(true)
            .Verifiable();

            this.validator = new ProductDataValidator(this.ruleValidator.Object,
                                                      this.productCategorizer.Object,
                                                      productsList);

            string content = "tegj pish prok";

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

            Assert.IsNotEmpty(results);
            Assert.Greater(productsList.Count, cacheCount);
            Assert.AreEqual(cacheCount + results.Count(), productsList.Count);

            this.productCategorizer.Verify(i => i.IsProductValid(It.IsAny <string>()), Times.AtLeastOnce);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }