public void should_not_throw_when_opted_out()
        {
            registry.ThrowOnRecursion(true);
            var newRegistry  = new ConstruktionRegistry().ThrowOnRecursion(false);
            var construktion = new Construktion().Apply(registry).Apply(newRegistry);

            Should.NotThrow(() => construktion.Construct <Parent>());
        }
        public void should_still_throw()
        {
            registry.ThrowOnRecursion(true);
            var newRegistry  = new ConstruktionRegistry();
            var construktion = new Construktion().Apply(registry).Apply(newRegistry);

            Exception <Exception> .ShouldBeThrownBy(() => construktion.Construct <Parent>());
        }
예제 #3
0
        public void should_register_property_attribute_blueprint()
        {
            var registry = new ConstruktionRegistry().AddPropertyAttribute <Set>(x => x.Value);

            var foo = new Construktion().Apply(registry).Construct <Foo>();

            foo.WithAttribute.ShouldBe("Set");
        }
예제 #4
0
        public void should_be_linq_enabled()
        {
            var reg = new ConstruktionRegistry(x => x.AddBlueprint <StringOneBlueprint>());

            var result = construktion.Apply(reg).Construct <string>();

            result.ShouldBe("StringOne");
        }
예제 #5
0
        public void should_be_linq_enabled()
        {
            var _registry = new ConstruktionRegistry(x => x.AddExitBlueprint <StringExitOneBlueprint>());

            var result = construktion.Apply(_registry).Construct <string>();

            result.ShouldEndWith("One");
        }
예제 #6
0
        public void should_construct_top_level_properties()
        {
            var registry     = new ConstruktionRegistry(x => x.MaxDepth(1));
            var construktion = new Construktion().Apply(registry);

            var result = construktion.Construct <LevelOne>();

            result.LevelTwo.ShouldNotBe(null);
            result.LevelTwo.Name.ShouldBe(null);
        }
예제 #7
0
        public void should_construct_using_supplied_function()
        {
            var registry =
                new ConstruktionRegistry().ConstructPropertyUsing(p => p.Name.Equals("Credits"),
                                                                  () => new Random().Next(1, 5));
            var construktion = new Construktion().Apply(registry);

            var foo = construktion.Construct <Foo>();

            foo.Credits.ShouldBeInRange(1, 4);
        }
예제 #8
0
        public void new_registries_without_a_setting_should_not_overwrite()
        {
            var registry     = new ConstruktionRegistry(x => x.MaxDepth(1));
            var registry2    = new ConstruktionRegistry();
            var construktion = new Construktion().Apply(registry).Apply(registry2);

            var result = construktion.Construct <LevelOne>();

            result.LevelTwo.ShouldNotBe(null);
            result.LevelTwo.Name.ShouldBe(null);
        }
예제 #9
0
        public void new_registries_should_overwrite_previous()
        {
            var registry     = new ConstruktionRegistry(x => x.MaxDepth(2));
            var registry2    = new ConstruktionRegistry(x => x.MaxDepth(1));
            var construktion = new Construktion().Apply(registry).Apply(registry2);

            var result = construktion.Construct <LevelOne>();

            result.LevelTwo.ShouldNotBe(null);
            result.LevelTwo.Name.ShouldBe(null);
        }
예제 #10
0
        public void should_construct_deeper()
        {
            var registry     = new ConstruktionRegistry(x => x.MaxDepth(2));
            var construktion = new Construktion().Apply(registry);

            var result = construktion.Construct <LevelOne>();

            result.LevelTwo.ShouldNotBe(null);
            result.LevelTwo.Name.ShouldNotBe(null);
            result.LevelTwo.LevelThree.ShouldNotBe(null);
            result.LevelTwo.LevelThree.Name.ShouldBe(null);
        }
예제 #11
0
        public void should_register_parameter_attribute_blueprint()
        {
            var registry = new ConstruktionRegistry().AddParameterAttribute <Set>(x => x.Value);

            var parameterInfo = typeof(ParameterAttributeTests)
                                .GetMethod(nameof(ParameterTest), BindingFlags.NonPublic | BindingFlags.Instance)
                                .GetParameters()
                                .Single();

            var parameter = (string)new Construktion().Apply(registry).Construct(parameterInfo);

            parameter.ShouldBe("Set");
        }
예제 #12
0
 public ExitBlueprintTests()
 {
     registry     = new ConstruktionRegistry();
     construktion = new Construktion();
 }
 public RegisteredInstanceTests()
 {
     registry     = new ConstruktionRegistry();
     construktion = new Construktion();
 }
예제 #14
0
 public EnumerableUsageTests()
 {
     registry     = new ConstruktionRegistry();
     construktion = new Construktion();
 }
 public ConstructorSelectionTests()
 {
     registry     = new ConstruktionRegistry();
     construktion = new Construktion();
 }
예제 #16
0
 public PropertySelectionTests()
 {
     registry     = new ConstruktionRegistry();
     construktion = new Construktion();
 }
예제 #17
0
 public OmitPropertiesTests()
 {
     registry     = new ConstruktionRegistry();
     construktion = new Construktion();
 }
 public ThrowingRecursionTests()
 {
     registry = new ConstruktionRegistry();
 }