/// <summary> /// Creates a Hive mapping group for templates /// </summary> /// <param name="frameworkContext"></param> /// <param name="path"></param> /// <returns></returns> public static ProviderMappingGroup CreateFakeTemplateMappingGroup(FakeFrameworkContext frameworkContext, string path = "") { string binPath; if (path.IsNullOrWhiteSpace()) { binPath = Path.Combine(Common.CurrentAssemblyDirectory, "Templates"); } else { binPath = path; } // TODO: Would rather we weren't creating files during unit tests esp unless their paths are thread-agnostic and we're sure of deleting them too (APN) using (new WriteLockDisposable(_fileCreationLocker)) { //ensure the folder exists if (!Directory.Exists(binPath)) { Directory.CreateDirectory(binPath); } //create 3 empty template files var homePagePath = Path.Combine(binPath, "home-page.cshtml"); var textPagePath = Path.Combine(binPath, "text-page.cshtml"); var faqPagePath = Path.Combine(binPath, "faq-page.cshtml"); if (!File.Exists(homePagePath)) { File.Create(homePagePath); } if (!File.Exists(textPagePath)) { File.Create(textPagePath); } if (!File.Exists(faqPagePath)) { File.Create(faqPagePath); } } var providerMetadata = new ProviderMetadata("templates", new Uri("storage://templates"), true, false); var dependencyHelper = new DependencyHelper(new Settings("*.cshtml", binPath, "/", "", "", "~/"), providerMetadata); var entityRepositoryFactory = new EntityRepositoryFactory(providerMetadata, null, null, frameworkContext, dependencyHelper); var readUnitFactory = new ReadonlyProviderUnitFactory(entityRepositoryFactory); var readWriteUnitFactory = new ProviderUnitFactory(entityRepositoryFactory); var bootstrapper = new FakeHiveProviderBootstrapper(); var readonlyProviderSetup = new ReadonlyProviderSetup(readUnitFactory, providerMetadata, frameworkContext, bootstrapper, 0); var providerSetup = new ProviderSetup(readWriteUnitFactory, providerMetadata, frameworkContext, bootstrapper, 0); var uriMatch = new WildcardUriMatch(new Uri("storage://templates")); var persistenceMappingGroup = new ProviderMappingGroup( "templates", uriMatch, readonlyProviderSetup, providerSetup, frameworkContext); return(persistenceMappingGroup); }
public ProviderMappingGroup(string key, WildcardUriMatch singleMatch, ReadonlyProviderSetup singleReader, ProviderSetup singleWriter, IFrameworkContext frameworkContext) : this(key, Enumerable.Repeat(singleMatch, 1), Enumerable.Repeat(singleReader, 1), Enumerable.Repeat(singleWriter, 1), frameworkContext) { Mandate.ParameterNotNull(singleReader, "singleReader"); Mandate.ParameterNotNull(singleWriter, "singleWriter"); }
private ProviderMappingGroup CreateFakeDictionaryMappingGroup(FakeFrameworkContext frameworkContext) { var helper = new NhibernateTestSetupHelper(frameworkContext, useNhProf:true); var uriMatch = new WildcardUriMatch(new Uri("dictionary://")); var persistenceMappingGroup = new ProviderMappingGroup( "dictionary", uriMatch, helper.ReadonlyProviderSetup, helper.ProviderSetup, frameworkContext); return persistenceMappingGroup; }
/// <summary> /// Creates a new HiveManager with an Examine default mapping group and the supplied provider mapping groups appended /// </summary> /// <param name="providerMappingGroups"></param> /// <param name="frameworkContext"></param> /// <returns></returns> public static IHiveManager NewWithExamine(IEnumerable <ProviderMappingGroup> providerMappingGroups, FakeFrameworkContext frameworkContext) { var helper = new ExamineTestSetupHelper(frameworkContext); var uriMatch = new WildcardUriMatch(new Uri("content://")); var persistenceMappingGroup = new ProviderMappingGroup( "default", uriMatch, helper.ReadonlyProviderSetup, helper.ProviderSetup, frameworkContext); return(new HiveManager(new[] { persistenceMappingGroup }.Union(providerMappingGroups), frameworkContext)); }
public UriMatchRegex(WildcardUriMatch uriMatch, Regex regex) { UriMatch = uriMatch; Regex = regex; }
public ProviderGroupMatchResult(WildcardUriMatch uriMatch, ProviderMappingGroup @group) { UriMatch = uriMatch; Group = @group; }
public ProviderUriMatchResult(bool success, WildcardUriMatch matchingUri) { Success = success; MatchingUri = matchingUri; }