Exemplo n.º 1
0
        public void Test_FindControllers()
        {
            string appName = "MockApplication";

            string[] assemblyPaths = new string[] {
                Assembly.Load("SoftwareMonkeys.SiteStarter.Web").Location
            };

            ControllerScanner scanner = new ControllerScanner();

            scanner.FileNamer.FileMapper = new MockFileMapper(this, TestUtilities.GetTestingPath(this), appName);
            scanner.AssemblyPaths        = assemblyPaths;

            //CreateMockControllers(scanner.FileNamer);

            ControllerInfo[] infos = scanner.FindControllers(true);

            Assert.Greater(infos.Length, 1, "Invalid number of controllers found.");

            string expectedLongType = typeof(CreateController).FullName + ", " + typeof(CreateController).Assembly.GetName().Name;

            Assert.AreEqual("Create", infos[0].Action, "The action doesn't match.");
            Assert.AreEqual("IEntity", infos[0].TypeName, "The type name doesn't match.");
            Assert.AreEqual(expectedLongType, infos[0].ControllerType, "The full controller component type name doesn't match.");
        }
Exemplo n.º 2
0
        public void Test_IsController()
        {
            ControllerScanner scanner = new ControllerScanner();

            CreateController controller = new CreateController();

            bool isController = scanner.IsController(controller.GetType());

            Assert.IsTrue(isController, "CreateController class is not recognised as a controller as it should be.");
        }
        protected void InitializeMockControllers()
        {
            string webAssemblyPath = Assembly.Load("SoftwareMonkeys.SiteStarter.Web").Location;

            string[] assemblyPaths = new String[] { webAssemblyPath };

            ControllersInitializer initializer = new ControllersInitializer();

            ControllerScanner scanner = new ControllerScanner();

            // Set the specific assemblies used during testing as it can't do it automatically in the mock environment
            scanner.AssemblyPaths = assemblyPaths;

            initializer.Scanners = new ControllerScanner[] { scanner };

            initializer.Initialize(true);
        }