Exemplo n.º 1
0
        public void AreItemPropertyValuesEqual_MultiPropertyValueMutliConditionValue_Succeeded()
        {
            // Arrange
            var context = new AssociationExpressionEvaluationContext()
            {
                Products = new[]
                {
                    new CatalogProduct
                    {
                        Properties = new [] {
                            new Property()
                            {
                                Name       = "DictionaryProperty",
                                Dictionary = true,
                                Values     = new []
                                {
                                    new PropertyValue()
                                    {
                                        Value   = "Elem1",
                                        Alias   = "Elem1",
                                        ValueId = "Elem1Id",
                                    },
                                    new PropertyValue()
                                    {
                                        Value   = "Elem2",
                                        Alias   = "Elem2",
                                        ValueId = "Elem2Id",
                                    },
                                }
                            }
                        },
                    }
                }
            };
            var valuesToMatch = new Dictionary <string, string[]>
            {
                { "DictionaryProperty", new[] { "Elem1", "Elem3" } }
            };

            // Act
            var result = context.AreItemPropertyValuesEqual(valuesToMatch);

            // Assert
            Assert.True(result);
        }
Exemplo n.º 2
0
        public void AreItemsInCategory_EmptyProduct_Failed()
        {
            // Arrange
            var context = new AssociationExpressionEvaluationContext()
            {
                Products = new[]
                {
                    new CatalogProduct {
                    },
                }
            };
            var categoryIds = new string[] { "noMatches" };

            // Act
            var result = context.AreItemsInCategory(categoryIds);

            // Assert
            Assert.False(result);
        }
Exemplo n.º 3
0
        public void AreItemsInCategory_MatchesCategoryId_Succeeded()
        {
            // Arrange
            var context = new AssociationExpressionEvaluationContext()
            {
                Products = new[]
                {
                    new CatalogProduct
                    {
                        CategoryId = "cat1",
                    }
                }
            };
            var categoryIds = new string[] { "cat1" };

            // Act
            var result = context.AreItemsInCategory(categoryIds);

            // Assert
            Assert.True(result);
        }
Exemplo n.º 4
0
        public void AreItemPropertyValuesEqual_MutliPropertyValueSingleConditionValue_Succeeded()
        {
            // Arrange
            var context = new AssociationExpressionEvaluationContext()
            {
                Products = new[]
                {
                    new CatalogProduct
                    {
                        Properties = new [] {
                            new Property()
                            {
                                Name   = "IntProperty",
                                Values = new []
                                {
                                    new PropertyValue()
                                    {
                                        Value = 1
                                    },
                                    new PropertyValue()
                                    {
                                        Value = 2
                                    },
                                }
                            }
                        },
                    }
                }
            };
            var valuesToMatch = new Dictionary <string, string[]>
            {
                { "IntProperty", new[] { "1" } }
            };

            // Act
            var result = context.AreItemPropertyValuesEqual(valuesToMatch);

            // Assert
            Assert.True(result);
        }
Exemplo n.º 5
0
        public void AreItemsInCategory_NotMatchingOutline_Failed()
        {
            // Arrange
            var context = new AssociationExpressionEvaluationContext()
            {
                Products = new[]
                {
                    new CatalogProduct
                    {
                        Outlines = new []
                        {
                            new Outline()
                            {
                                Items = new []
                                {
                                    new OutlineItem()
                                    {
                                        Id = "outerCat"
                                    },
                                    new OutlineItem()
                                    {
                                        Id = "innerCat"
                                    },
                                },
                            }
                        },
                    },
                }
            };
            var categoryIds = new string[] { "noMatches" };

            // Act
            var result = context.AreItemsInCategory(categoryIds);

            // Assert
            Assert.False(result);
        }
Exemplo n.º 6
0
        public void AreItemPropertyValuesEqual_DifferentPropertyValue_Failed()
        {
            // Arrange
            var context = new AssociationExpressionEvaluationContext()
            {
                Products = new[]
                {
                    new CatalogProduct
                    {
                        Properties = new [] {
                            new Property()
                            {
                                Name   = "IntProperty",
                                Values = new []
                                {
                                    new PropertyValue()
                                    {
                                        Value = 1
                                    }
                                }
                            }
                        },
                    }
                }
            };
            var valuesToMatch = new Dictionary <string, string[]>
            {
                { "IntProperty", new[] { "2" } }
            };

            // Act
            var result = context.AreItemPropertyValuesEqual(valuesToMatch);

            // Assert
            Assert.False(result);
        }