コード例 #1
0
 public void CreateConstructionInfo_ExternalMethodCallInObjectInitializer_ReturnsDependencyAsExpression()
 {
     var builder = new LambdaConstructionInfoBuilder();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithProperyDependency { Bar = this.GetInstance() };
     var constructionInfo = builder.Execute(e);
     Assert.IsTrue(constructionInfo.PropertyDependencies[0].FactoryExpression != null);
 }
コード例 #2
0
 public void CreateConstructionInfo_GetAllInstancesInConstructor_ReturnsConstructionInfoWithServiceType()
 {
     var builder = new LambdaConstructionInfoBuilder();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithEnumerableDependency(f.GetAllInstances<IBar>());
     var constructionInfo = builder.Execute(e);
     Assert.IsTrue(constructionInfo.ConstructorDependencies[0].ServiceType == typeof(IEnumerable<IBar>));
 }
コード例 #3
0
 public void CreateConstructionInfo_NewOperatorInConstructor_ReturnsConstructionInfo()
 {
     var builder = new LambdaConstructionInfoBuilder();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithDependency(new Bar());
     var constructionInfo = builder.Execute(e);
     Assert.AreEqual(typeof(FooWithDependency), constructionInfo.ImplementingType);
 }
コード例 #4
0
 public void CreateConstructionInfo_GetInstanceInObjectInitializer_ReturnsConstructionInfoWithServiceType()
 {
     var builder = new LambdaConstructionInfoBuilder();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithProperyDependency { Bar = f.GetInstance<IBar>() };
     var constructionInfo = builder.Execute(e);
     Assert.IsTrue(constructionInfo.PropertyDependencies[0].ServiceType == typeof(IBar));            
 }
コード例 #5
0
 public void CreateConstructionInfo_NamedGetInstanceInConstructor_ReturnsConstructionInfoWithServiceName()
 {
     var builder = new LambdaConstructionInfoBuilder();
     Expression<Func<IServiceFactory, IFoo>> e = f => new FooWithDependency(f.GetInstance<IBar>("SomeBar"));
     var ConstructionInfo = builder.Execute(e);
     Assert.IsTrue(ConstructionInfo.ConstructorDependencies[0].ServiceType == typeof(IBar));
     Assert.IsTrue(ConstructionInfo.ConstructorDependencies[0].ServiceName == "SomeBar");
 }
コード例 #6
0
        public void CreateConstructionInfo_GetAllInstancesInConstructor_ReturnsConstructionInfoWithServiceType()
        {
            var builder = new LambdaConstructionInfoBuilder();
            Expression <Func <IServiceFactory, IFoo> > e = f => new FooWithEnumerableDependency(f.GetAllInstances <IBar>());
            var constructionInfo = builder.Execute(e);

            Assert.IsTrue(constructionInfo.ConstructorDependencies[0].ServiceType == typeof(IEnumerable <IBar>));
        }
コード例 #7
0
        public void CreateConstructionInfo_NewOperatorInConstructor_ReturnsConstructionInfo()
        {
            var builder = new LambdaConstructionInfoBuilder();
            Expression <Func <IServiceFactory, IFoo> > e = f => new FooWithDependency(new Bar());
            var constructionInfo = builder.Execute(e);

            Assert.AreEqual(typeof(FooWithDependency), constructionInfo.ImplementingType);
        }
コード例 #8
0
        public void CreateConstructionInfo_WithParameters_ReturnsExpression()
        {
            var builder = new LambdaConstructionInfoBuilder();
            Expression <Func <IServiceFactory, int, IFoo> > e = (f, a) => new FooWithValueTypeDependency(a);
            var constructionInfo = builder.Execute(e);

            Assert.IsNotNull(constructionInfo.FactoryDelegate);
        }
コード例 #9
0
        public void CreateConstructionInfo_NamedGetInstanceInConstructor_ReturnsConstructionInfoWithServiceName()
        {
            var builder = new LambdaConstructionInfoBuilder();
            Expression <Func <IServiceFactory, IFoo> > e = f => new FooWithDependency(f.GetInstance <IBar>("SomeBar"));
            var ConstructionInfo = builder.Execute(e);

            Assert.IsTrue(ConstructionInfo.ConstructorDependencies[0].ServiceType == typeof(IBar));
            Assert.IsTrue(ConstructionInfo.ConstructorDependencies[0].ServiceName == "SomeBar");
        }
コード例 #10
0
        public void CreateConstructionInfo_ExternalMethodCallInObjectInitializer_ReturnsDependencyAsExpression()
        {
            var builder = new LambdaConstructionInfoBuilder();
            Expression <Func <IServiceFactory, IFoo> > e = f => new FooWithProperyDependency {
                Bar = this.GetInstance()
            };
            var constructionInfo = builder.Execute(e);

            Assert.IsTrue(constructionInfo.PropertyDependencies[0].FactoryExpression != null);
        }
コード例 #11
0
        public void CreateConstructionInfo_GetInstanceInObjectInitializer_ReturnsConstructionInfoWithServiceType()
        {
            var builder = new LambdaConstructionInfoBuilder();
            Expression <Func <IServiceFactory, IFoo> > e = f => new FooWithProperyDependency {
                Bar = f.GetInstance <IBar>()
            };
            var constructionInfo = builder.Execute(e);

            Assert.IsTrue(constructionInfo.PropertyDependencies[0].ServiceType == typeof(IBar));
        }
コード例 #12
0
 public void CreateConstructionInfo_WithParameters_ReturnsExpression()
 {
     var builder = new LambdaConstructionInfoBuilder();
     Expression<Func<IServiceFactory, int , IFoo>> e = (f,a) => new FooWithValueTypeDependency(a);
     var constructionInfo = builder.Execute(e);
     Assert.IsNotNull(constructionInfo.FactoryDelegate);
 }