Beispiel #1
0
        public void should_not_match_reference_types()
        {
            var blueprint = new NullableTypeBlueprint();
            var context   = new ConstruktionContext(typeof(Foo));

            var matches = blueprint.Matches(context);

            matches.ShouldBe(false);
        }
Beispiel #2
0
        public void should_not_match_non_nullable_type()
        {
            var blueprint = new NullableTypeBlueprint();
            var context   = new ConstruktionContext(typeof(Foo).GetProperty("NonNullableAge"));

            var matches = blueprint.Matches(context);

            matches.ShouldBe(false);
        }
Beispiel #3
0
        public void nullable_type_should_be_null_sometimes()
        {
            var blueprint = new NullableTypeBlueprint();
            var context   = new ConstruktionContext(typeof(Foo).GetProperty("NullableAge"));

            var values = new List <int?>();

            for (var i = 0; i <= 30; i++)
            {
                var value = blueprint.Construct(context, new DefaultConstruktionPipeline());
                values.Add((int?)value);
            }

            values.Any(x => x == null).ShouldBe(true);
            values.Any(x => x != null).ShouldBe(true);
        }