Esempio n. 1
0
        public async Task FilterBy_StoreAndUsualProperty_SetUserGroup()
        {
            var secondUsualDynamicProperty = (DynamicObjectProperty)UsualDynamicProperty.Clone();

            secondUsualDynamicProperty.Name = "Test Property";
            secondUsualDynamicProperty.Values.First().Value = "Test";
            var properties     = new[] { UsualDynamicProperty, secondUsualDynamicProperty };
            var store1Customer = new Contact
            {
                Id = "Customer1",
                SecurityAccounts = new[] { new ApplicationUser {
                                               StoreId = "Store1"
                                           } },
                DynamicProperties = properties
            };
            var store2Customer = new Contact
            {
                Id = "Customer2",
                SecurityAccounts = new[] { new ApplicationUser {
                                               StoreId = "Store2"
                                           } },
                DynamicProperties = properties
            };
            var segment = CreateCustomerSegment(new[] { UsualDynamicProperty }, new[] { "Store1" }, "Test");

            var documents = await BuildIndexDocuments(segment, store1Customer, store2Customer);

            Assert.Equal("Test", GetUserGroups(documents[0]).ToString());
            Assert.Null(GetUserGroups(documents[1]));
        }
Esempio n. 2
0
        public async Task FilterBy_NotMatchingUsualPropertyValue_DoNotSetUserGroup()
        {
            var usualPropertyWithDifferentValue = (DynamicObjectProperty)UsualDynamicProperty.Clone();

            usualPropertyWithDifferentValue.Values.First().Value = "Test";
            var properties = new[] { usualPropertyWithDifferentValue };
            var segment    = CreateCustomerSegment(
                properties,
                new[] { "Store" },
                "Test");
            var customer = GetCustomer(UsualDynamicProperty);

            var documents = await BuildIndexDocuments(segment, customer);

            Assert.Null(GetUserGroups(documents[0]));
        }