Beispiel #1
0
        public void Test_GetProperties_With_A_Type_That_Has_SerializablePropertyAttribute()
        {
            Type   type      = typeof(string);
            string container = string.Empty;
            IReadOnlyList <IPropertyDescriptor> expectedPropertyDescriptors = new List <IPropertyDescriptor>
            {
                DescriptorWithSerializablePropertyAttribute(new SerializablePropertyAttribute(0)),
                DescriptorWithSerializablePropertyAttribute(new SerializablePropertyAttribute(1, "Property")),
            };
            IEnumerable <IPropertyDescriptor> input = expectedPropertyDescriptors.Concat(new List <IPropertyDescriptor>
            {
                Substitute.For <IPropertyDescriptor>()
            });

            innerTypeInspector.GetProperties(type, container).Returns(input);

            var result = typeInspector.GetProperties(type, container);

            innerTypeInspector.Received().GetProperties(type, container);

            result.Should().NotBeNull().And.HaveCount(expectedPropertyDescriptors.Count);

            result.ForEach((propertyDescriptor, index) =>
            {
                var expectedPropertyDescriptor = expectedPropertyDescriptors[index];

                expectedPropertyDescriptor.Name.Should().Be(expectedPropertyDescriptor.Name);
                expectedPropertyDescriptor.Order.Should().Be(expectedPropertyDescriptor.Order);
            });
        }