public void CreateControllerShouldReturnErrorControllerForUnregisteredController() { var containerMock = new Mock<IDIContainer>(); ControllerFactory target = new ControllerFactory(containerMock.Object); // TODO: Initialize to an appropriate value RequestContext requestContext = null; // TODO: Initialize to an appropriate value string controllerName = "foobar"; // TODO: Initialize to an appropriate value containerMock.Setup(c => c.IsRegistered<IController>(controllerName)).Returns(false); containerMock.Setup(c => c.Resolve<IController>("null")).Returns(new NullController(null)); IController actual; actual = target.CreateController(requestContext, controllerName); Assert.IsInstanceOfType(actual, typeof(NullController)); }
public void CreateControllerShouldCallResolveWithControllerName() { var containerMock = new Mock<IDIContainer>(); ControllerFactory target = new ControllerFactory(containerMock.Object); // TODO: Initialize to an appropriate value RequestContext requestContext = null; // TODO: Initialize to an appropriate value string controllerName = "foobar"; // TODO: Initialize to an appropriate value containerMock.Setup(c => c.Resolve<IController>("foobar")).Returns(default(IController)); containerMock.Setup(c => c.IsRegistered<IController>("foobar")).Returns(true); IController actual; actual = target.CreateController(requestContext, controllerName); containerMock.VerifyAll(); }