Ejemplo n.º 1
0
		public void GetControllerInstance_should_return_null_from_null_type()
		{
			//arrange
			var controllerModule = new ControllerModule { TestController = new TestController() };
			var kernel = new StandardKernel(controllerModule);
			var target = new ControllerFactoryStub(kernel);
			target.TypeMapping = Tuple.Create<string, Type>("Test", null);
			//act
			var actual = target.CreateController(Substitute.For<RequestContext>(), "Test");
			//assert
			Assert.IsNull(actual);
		}
Ejemplo n.º 2
0
		public void GetContollerInstance_should_initialize_CommitProviderInstance()
		{
			//arrange
			var controllerModule = new ControllerModule { TestBaseController = new TestBaseController(), CommitProvider = Substitute.For<ICommitProvider>() };
			var kernel = new StandardKernel(controllerModule);
			var target = new ControllerFactoryStub(kernel);
			target.TypeMapping = Tuple.Create<string, Type>("Test", typeof(TestBaseController));
			//act
			var actual = target.CreateController(Substitute.For<RequestContext>(), "Test");
			//assert
			Assert.AreSame(controllerModule.CommitProvider, (actual as TestBaseController).CommitProviderInstance);
		}
Ejemplo n.º 3
0
		public void GetControllerInstance_should_return_instance_from_ResolutionRoot()
		{
			//arrange
			var controllerModule = new ControllerModule { TestController = new TestController() };
			var kernel = new StandardKernel(controllerModule);
			var target = new ControllerFactoryStub(kernel);
			target.TypeMapping = Tuple.Create<string, Type>("Test", typeof(TestController));
			//act
			var actual = target.CreateController(Substitute.For<RequestContext>(), "Test");
			//assert
			Assert.AreSame(controllerModule.TestController, actual);
		}