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(); }
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(); }
public void AllPropertiesAreSavedToPropertyBag() { var sut = CreatePipelineComponent(); var propertyBag = new PropertyBag(); sut.Save(propertyBag, false, false); BrowsableProperties.Each( p => Assert.That( propertyBag.Contains(p.Name), string.Format( "{0} property has not been written to IPropertyBag. Notice that, for a string property, an empty string value should always be written even if it is null or empty.", p.Name))); }
public void AllPropertiesConvertToStringAndBack() { var sut = CreatePipelineComponent(); BrowsableProperties.Each(p => new BaggableProperty(p, GetValueForProperty).EnsureConvertToStringAndBack(p.GetValue(sut, null))); }