Esempio 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));
            }
        }
        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);
        }
Esempio 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));
            }
        }
 public override bool DirectoryExists(string virtualDir)
 {
     return(Directory.Exists(MockVirtualPathFactory.NormalizePath(virtualDir)));
 }
 public override bool FileExists(string virtualPath)
 {
     return(File.Exists(MockVirtualPathFactory.NormalizePath(virtualPath)));
 }