public void GetTypeConfiguration_TwoInterfacesWithTheSameNameUsingCastleProxy_ReturnsEachCorrectly()
        {
            //Arrange
            string contextName = "testContext";
            bool   isDefault   = true;
            var    type        = typeof(NS1.ProxyTest1);
            var    service     = Substitute.For <IAbstractService>();
            var    task        = new CreateInterfaceTask(new LazyLoadingHelper());

            #region CreateTypes

            Context context = Context.Create(Substitute.For <IDependencyResolver>());
            context.Config = new Config();
            AbstractTypeCreationContext abstractTypeCreationContext1 = new TestTypeCreationContext();
            abstractTypeCreationContext1.Options = new TestGetOptions()
            {
                Type = typeof(NS1.ProxyTest1)
            };

            var configuration1 = Substitute.For <AbstractTypeConfiguration>();
            configuration1.Type = typeof(NS1.ProxyTest1);

            ObjectConstructionArgs args1 = new ObjectConstructionArgs(context, abstractTypeCreationContext1, configuration1, service);

            AbstractTypeCreationContext abstractTypeCreationContext2 = new TestTypeCreationContext();

            abstractTypeCreationContext2.Options = new TestGetOptions()
            {
                Type = typeof(NS2.ProxyTest1)
            };
            var configuration2 = Substitute.For <AbstractTypeConfiguration>();
            configuration2.Type = typeof(NS2.ProxyTest1);

            ObjectConstructionArgs args2 = new ObjectConstructionArgs(context, abstractTypeCreationContext2, configuration2, service);

            //Act
            task.Execute(args1);
            task.Execute(args2);

            #endregion

            context.GetTypeConfigurationFromType <StubAbstractTypeConfiguration>(typeof(NS1.ProxyTest1));
            context.GetTypeConfigurationFromType <StubAbstractTypeConfiguration>(typeof(NS2.ProxyTest1));


            //Act
            var config1 = context.GetTypeConfigurationFromType <StubAbstractTypeConfiguration>(args1.Result.GetType());
            var config2 = context.GetTypeConfigurationFromType <StubAbstractTypeConfiguration>(args2.Result.GetType());

            //Assert
            Assert.AreEqual(typeof(NS1.ProxyTest1), config1.Type);
            Assert.AreEqual(typeof(NS2.ProxyTest1), config2.Type);
        }
 public void Setup()
 {
     _task = new CreateInterfaceTask();
 }
Example #3
0
 public void Setup()
 {
     _task = new CreateInterfaceTask(new LazyLoadingHelper());
 }