Exemple #1
0
        public void It_should_build_a_function_that_recursively_sets_all_public_properties_and_fields_to_an_empty_value()
        {
            var transform = new FillWithEmptyValuesTransformFactory().GetTransform <ClassA>();

            var instanceOfA = new ClassA();

            transform.ApplyTo(instanceOfA);

            instanceOfA.PublicProperty.Should().Be(string.Empty);
            instanceOfA.PublicField.Should().Be(string.Empty);
            instanceOfA.NullableProperty.Should().Be(0);
            instanceOfA.NullableField.Should().Be(0);
            instanceOfA.B.Should().NotBeNull();

            var instanceOfB = instanceOfA.B;

            instanceOfB.Property.Should().Be(string.Empty);
            instanceOfB.PublicField.Should().Be(string.Empty);
            instanceOfB.NullableProperty.Should().Be(0);
            instanceOfB.NullableField.Should().Be(0);
            instanceOfB.C.Should().NotBeNull();

            var instanceOfC = instanceOfB.C;

            instanceOfC.PublicProperty.Should().Be(string.Empty);
            instanceOfC.PublicField.Should().Be(string.Empty);
            instanceOfC.NullableProperty.Should().Be(0);
            instanceOfC.NullableField.Should().Be(0);
        }
Exemple #2
0
        public void It_should_build_a_function_that_initializes_all_supported_types()
        {
            var transform = new FillWithEmptyValuesTransformFactory().GetTransform <ClassA>();

            var instanceOfA = new ClassA();

            transform.ApplyTo(instanceOfA);

            instanceOfA.StringProperty.Should().Be(string.Empty);
            instanceOfA.DateTimeProperty.Should().Be(RecursiveTransformFactoryOptions.DefaultStartDate);
            instanceOfA.NullableByteProperty.Should().Be(0);
            instanceOfA.NullableShortProperty.Should().Be(0);
            instanceOfA.NullableUShortProperty.Should().Be(0);
            instanceOfA.NullableIntProperty.Should().Be(0);
            instanceOfA.NullableUIntProperty.Should().Be(0);
            instanceOfA.NullableLongProperty.Should().Be(0);
            instanceOfA.NullableULongProperty.Should().Be(0);
            instanceOfA.NullableFloatProperty.Should().Be(0f);
            instanceOfA.NullableDoubleProperty.Should().Be(0d);
            instanceOfA.NullableDecimalProperty.Should().Be(0m);
            instanceOfA.NullableDateTimeProperty.Should().Be(RecursiveTransformFactoryOptions.DefaultStartDate);
        }