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>()); }
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"); }
public void should_be_linq_enabled() { var reg = new ConstruktionRegistry(x => x.AddBlueprint <StringOneBlueprint>()); var result = construktion.Apply(reg).Construct <string>(); result.ShouldBe("StringOne"); }
public void should_be_linq_enabled() { var _registry = new ConstruktionRegistry(x => x.AddExitBlueprint <StringExitOneBlueprint>()); var result = construktion.Apply(_registry).Construct <string>(); result.ShouldEndWith("One"); }
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); }
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); }
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); }
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); }
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); }
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"); }
public ExitBlueprintTests() { registry = new ConstruktionRegistry(); construktion = new Construktion(); }
public RegisteredInstanceTests() { registry = new ConstruktionRegistry(); construktion = new Construktion(); }
public EnumerableUsageTests() { registry = new ConstruktionRegistry(); construktion = new Construktion(); }
public ConstructorSelectionTests() { registry = new ConstruktionRegistry(); construktion = new Construktion(); }
public PropertySelectionTests() { registry = new ConstruktionRegistry(); construktion = new Construktion(); }
public OmitPropertiesTests() { registry = new ConstruktionRegistry(); construktion = new Construktion(); }
public ThrowingRecursionTests() { registry = new ConstruktionRegistry(); }