public void GetAllReferences_All_Variants_With_IDataValueReferenceFactory()
        {
            var collection = new DataValueReferenceFactoryCollection(() => new TestDataValueReferenceFactory().Yield());

            // label does not implement IDataValueReference
            var labelEditor = new LabelPropertyEditor(
                DataValueEditorFactory,
                IOHelper);
            var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(() => labelEditor.Yield()));
            var trackedUdi1     = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString();
            var trackedUdi2     = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString();
            var trackedUdi3     = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString();
            var trackedUdi4     = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString();
            var serializer      = new ConfigurationEditorJsonSerializer();
            var property        = new Property(new PropertyType(ShortStringHelper, new DataType(labelEditor, serializer))
            {
                Variations = ContentVariation.CultureAndSegment
            })
            {
                Values = new List <PropertyValue>
                {
                    // Ignored (no culture)
                    new PropertyValue
                    {
                        EditedValue = trackedUdi1
                    },
                    new PropertyValue
                    {
                        Culture     = "en-US",
                        EditedValue = trackedUdi2
                    },
                    new PropertyValue
                    {
                        Culture     = "en-US",
                        Segment     = "A",
                        EditedValue = trackedUdi3
                    },

                    // Ignored (no culture)
                    new PropertyValue
                    {
                        Segment     = "A",
                        EditedValue = trackedUdi4
                    },

                    // Duplicate
                    new PropertyValue
                    {
                        Culture     = "en-US",
                        Segment     = "B",
                        EditedValue = trackedUdi3
                    }
                }
            };
            var properties = new PropertyCollection
            {
                property
            };
            IEnumerable <UmbracoEntityReference> result = collection.GetAllReferences(properties, propertyEditors);

            Assert.AreEqual(2, result.Count());
            Assert.AreEqual(trackedUdi2, result.ElementAt(0).Udi.ToString());
            Assert.AreEqual(trackedUdi3, result.ElementAt(1).Udi.ToString());
        }
Beispiel #2
0
        public void GetAllReferences_All_Variants_With_IDataValueReferenceFactory()
        {
            var collection = new DataValueReferenceFactoryCollection(new TestDataValueReferenceFactory().Yield());

            // label does not implement IDataValueReference
            var labelEditor     = new LabelPropertyEditor(Mock.Of <ILogger>());
            var propertyEditors = new PropertyEditorCollection(new DataEditorCollection(labelEditor.Yield()));
            var trackedUdi1     = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString();
            var trackedUdi2     = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString();
            var trackedUdi3     = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString();
            var trackedUdi4     = Udi.Create(Constants.UdiEntityType.Media, Guid.NewGuid()).ToString();
            var property        = new Property(new PropertyType(new DataType(labelEditor))
            {
                Variations = ContentVariation.CultureAndSegment
            })
            {
                Values = new List <PropertyValue>
                {
                    // Ignored (no culture)
                    new PropertyValue
                    {
                        EditedValue = trackedUdi1
                    },
                    new PropertyValue
                    {
                        Culture     = "en-US",
                        EditedValue = trackedUdi2
                    },
                    new PropertyValue
                    {
                        Culture     = "en-US",
                        Segment     = "A",
                        EditedValue = trackedUdi3
                    },
                    // Ignored (no culture)
                    new PropertyValue
                    {
                        Segment     = "A",
                        EditedValue = trackedUdi4
                    },
                    // duplicate
                    new PropertyValue
                    {
                        Culture     = "en-US",
                        Segment     = "B",
                        EditedValue = trackedUdi3
                    }
                }
            };
            var properties = new PropertyCollection
            {
                property
            };
            var result = collection.GetAllReferences(properties, propertyEditors);

            Assert.AreEqual(2, result.Count());
            Assert.AreEqual(trackedUdi2, result.ElementAt(0).Udi.ToString());
            Assert.AreEqual(trackedUdi3, result.ElementAt(1).Udi.ToString());
        }