예제 #1
0
 public TestClass2(ISomeInstance someInstance, string testProperty1, ISomeService someService, string testProperty3)
 {
     this.InjectedService = someService;
     this.TestProperty1   = testProperty1;
     this.TestProperty2   = someInstance;
     this.TestProperty3   = testProperty3;
 }
예제 #2
0
        public void given_instantiated_Sut_when_Create_is_called_with_two_parameters_and_parameter_2_is_null_then_TestProperty1_and_2_on_resulting_TestClass_matches_specified_values()
        {
            // Arrange
            using (var unityContainer = new UnityContainer())
            {
                unityContainer
                .RegisterAutoFactory <ITest2Factory, TestClass2Factory>()
                .UsingConcreteType <TestClass2>();

                const string  TestValue    = "TestValue";
                ISomeInstance someInstance = null;

                unityContainer.RegisterType <ISomeService, SomeService>(new ContainerControlledLifetimeManager());

                // Act
                var factory   = unityContainer.Resolve <ITest2Factory>();
                var testClass = factory.Create(string.Empty, someInstance, TestValue);

                // Assert
                Assert.AreEqual(string.Empty, testClass.TestProperty1);
                Assert.AreEqual(TestValue, testClass.TestProperty2);
                Assert.AreEqual(someInstance, testClass.TestProperty2);
                Assert.AreEqual(unityContainer.Resolve <ISomeService>(), testClass.InjectedService);
            }
        }
예제 #3
0
 public TestClass2NonMatchingName(
     ISomeInstance someInstance,
     string nonMatchingTestProperty1,
     ISomeService someService,
     string nonMatchingTestProperty3)
 {
     this.InjectedService = someService;
     this.TestProperty1   = nonMatchingTestProperty1;
     this.TestProperty2   = someInstance;
     this.TestProperty3   = nonMatchingTestProperty3;
 }
예제 #4
0
        public void given_instantiated_Sut_when_Create_is_called_with_two_parameters_and_parameter_2_is_null_then_ArgumentNullException_is_thrown()
        {
            // Arrange
            using (var unityContainer = new UnityContainer())
            {
                unityContainer
                .RegisterTypedFactory <ITest2Factory>()
                .ForConcreteType <TestClass2>();

                const string  TestValue    = "TestValue";
                ISomeInstance someInstance = null;

                unityContainer.RegisterType <ISomeService, SomeService>(new ContainerControlledLifetimeManager());

                // Act
                var factory = unityContainer.Resolve <ITest2Factory>();
                factory.Create(string.Empty, someInstance, TestValue);
            }
        }
 public TestClass2(ISomeInstance testProperty2, string testProperty1, ISomeService someService, string testProperty3)
 {
     this.InjectedService = someService;
     this.TestProperty3 = testProperty3;
     this.TestProperty1 = testProperty1;
     this.TestProperty2 = testProperty2;
 }
 public ITest2 Create(string testProperty1, ISomeInstance testProperty2, string testProperty3)
 {
     throw new System.NotImplementedException();
 }
 public TestClass2NonMatchingName(
     ISomeInstance someInstance,
     string nonMatchingTestProperty1,
     ISomeService someService,
     string nonMatchingTestProperty3)
 {
     this.InjectedService = someService;
     this.TestProperty1 = nonMatchingTestProperty1;
     this.TestProperty2 = someInstance;
     this.TestProperty3 = nonMatchingTestProperty3;
 }
예제 #8
0
 public ITest2 Create(string testProperty1, ISomeInstance testProperty2, string testProperty3)
 {
     throw new System.NotImplementedException();
 }