public void CreateServiceInfo_GetInstanceInConstructor_ReturnsServiceInfoWithServiceType()
 {
     var parser = new ServiceContainer.LambdaExpressionParser();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithDependency(f.GetInstance<IBar>());
     var serviceInfo = parser.Parse(e);
     Assert.IsTrue(serviceInfo.ConstructorDependencies[0].ServiceType == typeof(IBar));
 }
 public void CreateServiceInfo_GetInstanceInObjectInitializer_ReturnsServiceInfoWithServiceType()
 {
     var parser = new ServiceContainer.LambdaExpressionParser();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithProperyDependency { Bar = f.GetInstance<IBar>() };
     var serviceInfo = parser.Parse(e);
     Assert.IsTrue(serviceInfo.PropertyDependencies[0].ServiceType == typeof(IBar));
 }
 public void CreateServiceInfo_ExternalMethodCallInObjectInitializer_ReturnsDependencyAsExpression()
 {
     var parser = new ServiceContainer.LambdaExpressionParser();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithProperyDependency { Bar = this.GetInstance() };
     var serviceInfo = parser.Parse(e);
     Assert.IsTrue(serviceInfo.PropertyDependencies[0].Expression != null);
 }
 public void CreateServiceInfo_NewOperatorInConstructor_ReturnsServiceInfo()
 {
     var parser = new ServiceContainer.LambdaExpressionParser();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithDependency(new Bar());
     var serviceInfo = parser.Parse(e);
     Assert.AreEqual(typeof(FooWithDependency), serviceInfo.ImplementingType);
 }
 public void CreateServiceInfo_MethodCall_ThrowsInvalidOperationException()
 {
     var parser = new ServiceContainer.LambdaExpressionParser();
     Expression<Func<IServiceFactory, IBar>> e = f => this.GetInstance();
     ExceptionAssert.Throws<InvalidOperationException>(() => parser.Parse(e), ErrorMessages.InvalidFuncFactoryExpression);
 }