Exemple #1
0
        public void AllPropertyValuesAreSavedToPropertyBag()
        {
            var sut = CreatePipelineComponent();

            var propertyBagMock = new Mock <PropertyBag> {
                CallBase = true
            };

            BrowsableProperties.Each(
                p => {
                var baggableProperty = new BaggableProperty(p, GetValueForProperty).GenerateValue(p.GetValue(sut, null));
                // assign value to property to ensure sut.Save() will save it to the bag
                p.SetValue(sut, baggableProperty.ActualValue, null);
                propertyBagMock
                .Setup(pb => pb.Write(p.Name, baggableProperty.BaggedValue))
                .Verifiable(
                    string.Format(
                        "{0} property has not been written to IPropertyBag. Apply a [Browsable(false)] attribute to the property if it is intended.",
                        p.Name));
            });

            sut.Save(propertyBagMock.Object, true, true);

            propertyBagMock.Verify();
        }
Exemple #2
0
        public void AllPropertyValuesAreLoadedFromPropertyBag()
        {
            var sut = CreatePipelineComponent();

            var propertyBagMock = new Mock <PropertyBag> {
                CallBase = true
            };

            BrowsableProperties.Each(
                p => {
                var baggableProperty = new BaggableProperty(p, GetValueForProperty).GenerateValue(p.GetValue(sut, null));
                propertyBagMock.Object.Add(p.Name, baggableProperty.BaggedValue);
                propertyBagMock
                .Setup(pb => pb.Read(p.Name))
                .Returns(baggableProperty.BaggedValue)
                .Verifiable(
                    string.Format(
                        "{0} property has not been read from IPropertyBag. Apply a [Browsable(false)] attribute to the property if it is intended.",
                        p.Name));
            });

            sut.Load(propertyBagMock.Object, 0);

            propertyBagMock.Verify();
        }