public void CanCreateServiceResolutionExpressionFromConstructorExpression() { var container = new Registry() .Define <IServiceWithDependencies>() .As(req => new ServiceWithDependencies( Resolve.From <IServiceWithoutDependencies>(), "Hello world" )) .Define <IServiceWithoutDependencies>().As <ServiceWithoutDependencies>() .CreateContainer(); var service = container.GetService <IServiceWithDependencies>(); Assert.Equal("Hello world", service.Message); Assert.IsType <ServiceWithoutDependencies>(service.Dependency); }
public void CanCreateServiceResolutionExpressionFromFluentConstructorExpression() { var module = new Module(); module.Define <IServiceWithDependencies>().As(req => new ServiceWithDependencies( Resolve.From <IServiceWithoutDependencies>(), "Hello world" ) ); module.Define <IServiceWithoutDependencies>().As <ServiceWithoutDependencies>(); var configuration = new Configuration(_options, module); var container = configuration.CreateContainer(); var service = container.GetService <IServiceWithDependencies>(); Assert.Equal("Hello world", service.Message); Assert.IsType <ServiceWithoutDependencies>(service.Dependency); }