public void ItemBlockItemMatch_BaseTypeBlockItem_SingleBlockItemValue_ReturnsTrue(string testInputBaseType, bool expectedResult)
        {
            //Arrange
            var testInputItem = Mock.Of <IItem>(i => i.BaseType == "Test Base Type");
            var testInputBaseTypeBlockItem = new BaseTypeBlockItem();

            testInputBaseTypeBlockItem.Items.Add(testInputBaseType);

            //Act
            var result = _testUtility.BlockItemMatcher.ItemBlockItemMatch(testInputBaseTypeBlockItem, testInputItem);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
        public void ItemBlockMatch_SingleBlockItem_DoesNotMatche_ReturnsFalse()
        {
            //Arrange
            var testInputItem     = Mock.Of <IItem>(i => i.BaseType == "Base Type 1");
            var testInputBlock    = new ItemFilterBlock();
            var baseTypeBlockItem = new BaseTypeBlockItem();

            baseTypeBlockItem.Items.Add("Base Type 2");
            testInputBlock.BlockItems.Add(baseTypeBlockItem);

            //Act
            var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);

            //Assert
            Assert.IsFalse(result);
        }
        public void ItemBlockMatch_SingleBlockItem_Matches_ReturnsTrue()
        {
            //Arrange
            var testBaseType      = "Test Base Type";
            var testInputItem     = Mock.Of <IItem>(i => i.BaseType == testBaseType);
            var testInputBlock    = new ItemFilterBlock();
            var baseTypeBlockItem = new BaseTypeBlockItem();

            baseTypeBlockItem.Items.Add(testBaseType);
            testInputBlock.BlockItems.Add(baseTypeBlockItem);

            //Act
            var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);

            //Assert
            Assert.IsTrue(result);
        }
        public void ItemBlockMatch_MultipleBlockItems_DoesNotMatch_ReturnsFalse()
        {
            //Arrange
            var testInputItem     = Mock.Of <IItem>(i => i.BaseType == "Base Type 1" && i.Height == 4 && i.Width == 2);
            var testInputBlock    = new ItemFilterBlock();
            var baseTypeBlockItem = new BaseTypeBlockItem();

            baseTypeBlockItem.Items.Add("Base Type d");
            var heightBlockItem = new HeightBlockItem(FilterPredicateOperator.Equal, 3);
            var widthBlockItem  = new WidthBlockItem(FilterPredicateOperator.Equal, 2);

            testInputBlock.BlockItems.Add(baseTypeBlockItem);
            testInputBlock.BlockItems.Add(heightBlockItem);
            testInputBlock.BlockItems.Add(widthBlockItem);

            //Act
            var result = _testUtility.BlockItemMatcher.ItemBlockMatch(testInputBlock, testInputItem);

            //Assert
            Assert.IsFalse(result);
        }
Пример #5
0
 private static bool BaseTypeBlockItemMatch(BaseTypeBlockItem baseTypeBlockItem, IItem item)
 {
     return(baseTypeBlockItem.Items.Any(b => item.BaseType.StartsWith(b)));
 }