Ejemplo n.º 1
0
        public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
        {
            string controllerName = controllerContext.RouteData.GetRequiredString("controller");
            object area;
            string viewArea = null;

            if (controllerContext.RouteData.DataTokens.TryGetValue("area", out area))
            {
                viewArea = area as string;
            }
            var loc = ViewLocationFormats
                      .Select(x => String.Format(x, viewName, controllerName, viewArea))
                      .FirstOrDefault(s => File.Exists(MockVirtualPathFactory.NormalizePath(s)));
            var masterLoc = MasterLocationFormats
                            .Select(x => String.Format(x, viewName, masterName, viewArea))
                            .FirstOrDefault(s => File.Exists(MockVirtualPathFactory.NormalizePath(s)));

            if (loc == null)
            {
                return(new ViewEngineResult(ViewLocationFormats));
            }
            else
            {
                var view = new MockView(MockVirtualPathFactory.NormalizePath(loc), loc, true, FileExtensions);
                return(new ViewEngineResult(view, this));
            }
        }
Ejemplo n.º 2
0
        public override VirtualFile GetFile(string virtualPath)
        {
            var virtualMock = MockExtensions.Repository.Create <VirtualFile>(virtualPath);

            virtualMock.Setup(x => x.Open()).Returns(new FileStream(MockVirtualPathFactory.NormalizePath(virtualPath),
                                                                    FileMode.Open, FileAccess.Read, FileShare.Read));
            return(virtualMock.Object);
        }
Ejemplo n.º 3
0
        public override ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache)
        {
            string controllerName = controllerContext.RouteData.GetRequiredString("controller");
            object area;
            string viewArea = null;

            if (controllerContext.RouteData.DataTokens.TryGetValue("area", out area))
            {
                viewArea = area as string;
            }
            var loc = PartialViewLocationFormats
                      .Select(x => String.Format(x, partialViewName, controllerName, viewArea))
                      .FirstOrDefault(s => File.Exists(s.Replace("~/", MockVirtualPathFactory.BaseDirectory + "\\EPICCentral\\")));

            if (loc == null)
            {
                return(new ViewEngineResult(ViewLocationFormats));
            }
            else
            {
                var view = new MockView(MockVirtualPathFactory.NormalizePath(loc), loc, false, FileExtensions);
                return(new ViewEngineResult(view, this));
            }
        }
Ejemplo n.º 4
0
 public override bool DirectoryExists(string virtualDir)
 {
     return(Directory.Exists(MockVirtualPathFactory.NormalizePath(virtualDir)));
 }
Ejemplo n.º 5
0
 public override bool FileExists(string virtualPath)
 {
     return(File.Exists(MockVirtualPathFactory.NormalizePath(virtualPath)));
 }