Пример #1
0
            public void ShouldReturnTheController()
            {
                IControllerFactory factory = new SpringControllerFactory();
                IController controller = factory.CreateController(null,"Simple");

                Assert.That(controller, Is.Not.Null);
                Assert.That(controller, Is.AssignableFrom(typeof(SpringSimpleController)));
            }
Пример #2
0
            public void ShouldReturnControllerWithDependencies()
            {
                IControllerFactory factory = new SpringControllerFactory();
                IController controller = factory.CreateController(null, "Dependency");

                Assert.That(controller, Is.Not.Null);
                Assert.That(controller, Is.AssignableFrom(typeof(SpringDependencyController)));

                var dependencyController = (SpringDependencyController)controller;
                Assert.That(dependencyController._dependency, Is.Not.Null);
                Assert.That(dependencyController._dependency, Is.AssignableFrom(typeof(StubDependency)));
            }
Пример #3
0
 public void ShouldThrowExceptionForNullControllerName()
 {
     IControllerFactory factory = new SpringControllerFactory();
     IController controller = factory.CreateController(null, null);
 }
Пример #4
0
 public void ShouldThrowExceptionForInvalidController()
 {
     IControllerFactory factory = new SpringControllerFactory();
     IController controller = factory.CreateController(null, "NonValid");//typeof(NonValidController));
 }
Пример #5
0
            public void ShouldConfigureFactory()
            {
                string objectXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?> " +
                                   "  <objects xmlns=\"http://www.springframework.net\" " +
                                   "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " +
                                   "    xsi:schemaLocation=\"http://www.springframework.net http://www.springframework.net/xsd/spring-objects.xsd\"> " +
                                   "    <object id=\"SimpleController\" singleton=\"true\" type=\"MvcContrib.UnitTests.ControllerFactories.SpringControllerFactoryTester+WhenAValidControllerTypeIsPassed+SpringSimpleController\"/> " +
                                   "    <object id=\"DependencyController\" singleton=\"true\" type=\"MvcContrib.UnitTests.ControllerFactories.SpringControllerFactoryTester+WhenAValidControllerTypeIsPassed+SpringDependencyController\" > " +
                                   "      <constructor-arg> " +
                                   "        <object type=\"MvcContrib.UnitTests.ControllerFactories.SpringControllerFactoryTester+WhenAValidControllerTypeIsPassed+StubDependency\" /> " +
                                   "      </constructor-arg> " +
                                   "    </object> " +
                                   "  </objects>";
                Stream stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(objectXml));
                IResource resource = new InputStreamResource(stream, "In memory xml");
                var ctx = new GenericApplicationContext();
                var reader = new XmlObjectDefinitionReader(ctx);
                reader.LoadObjectDefinitions(resource);
                ctx.Refresh();
                SpringControllerFactory.Configure(ctx);
                IControllerFactory factory = new SpringControllerFactory();
                IController controller = factory.CreateController(null, "Simple");
                                                                  //Type.GetType("MvcContrib.UnitTests.ControllerFactories.SpringControllerFactoryTester+WhenAValidControllerTypeIsPassed+SimpleController"));

                Assert.That(controller, Is.Not.Null);
                Assert.That(controller, Is.AssignableFrom(typeof(WhenAValidControllerTypeIsPassed.SpringSimpleController)));
            }
Пример #6
0
 public void ControllerShouldBeDisposed()
 {
     var factory = new SpringControllerFactory();
     var controller = new SpringDisposableController();
     factory.ReleaseController(controller);
     Assert.That(controller.IsDisposed);
 }