public string GetActiveUrlByKey(Guid key, Type resourceType) { var fileName = RRContainer.GetAllResourceTypes().Single(x => x.GetType() == resourceType).FileName; return(SingleOrDefault <string>(@"SELECT FileName from RequestReduceFiles where [Key] = @0 and IsExpired=0 and FileName like @1", key, string.Format("{0}{1}", '%', fileName))); }
public string GetActiveUrlByKey(Guid key, Type resourceType) { var fileName = RRContainer.GetAllResourceTypes().Single(x => x.GetType() == resourceType).FileName; return((from files in AsQueryable() where files.Key == key && !files.IsExpired && files.FileName.Contains(fileName) select files.FileName).FirstOrDefault()); }
public void ResouceTypesAreSingletons() { var resources1 = RRContainer.GetAllResourceTypes(); var resources2 = RRContainer.GetAllResourceTypes(); var r1 = resources1.First(x => x is JavaScriptResource); var r2 = resources2.First(x => x is JavaScriptResource); Assert.Equal(r1, r2); }
public void StoreIsLocalDiskWhenConfigurationIsLocalDisk() { var container = new Container(); var config = Mock.Of <IRRConfiguration>(c => c.ContentStore == Configuration.Store.LocalDiskStore); container.Configure(x => { x.For <IRRConfiguration>().Use(config); x.For <IFileWrapper>().Use(Mock.Of <IFileWrapper>()); x.For <IUriBuilder>().Use(Mock.Of <IUriBuilder>()); x.For <IReductionRepository>().Use(Mock.Of <IReductionRepository>()); }); RRContainer.LoadAppropriateStoreRegistry(container); var result = container.GetInstance <IStore>(); Assert.IsType <LocalDiskStore>(result); }
public void StoreIsSqlServerWhenConfigurationIsSqlServerAndAssemblyExists() { var container = new Container(); var config = new Mock <IRRConfiguration>(); config.Setup(c => c.ContentStore).Returns(Configuration.Store.SqlServerStore); config.Setup(x => x.ConnectionStringName).Returns("RRConnection"); container.Configure(x => x.For <IRRConfiguration>().Use(config.Object)); container.Configure(x => { x.For <IUriBuilder>().Use(Mock.Of <IUriBuilder>()); x.For <IFileRepository>().Use(Mock.Of <IFileRepository>()); x.For <IReductionRepository>().Use(Mock.Of <IReductionRepository>()); x.For <IFileWrapper>().Use(Mock.Of <IFileWrapper>()); }); RRContainer.LoadAppropriateStoreRegistry(container); var result = container.GetInstance <IStore>(); Assert.IsType <SqlServerStore>(result); }
public void DbDiskCacheIsSingleton() { var container = RRContainer.Current; var config = new Mock <IRRConfiguration>(); config.Setup(c => c.ContentStore).Returns(Configuration.Store.SqlServerStore); config.Setup(x => x.ConnectionStringName).Returns("RRConnection"); container.Configure(x => x.For <IRRConfiguration>().Use(config.Object)); RRContainer.LoadAppropriateStoreRegistry(container); SqlServerStore store1 = null; SqlServerStore store2 = null; var thread1 = new Thread(TestThreadStart) { IsBackground = true }; var thread2 = new Thread(TestThreadStart) { IsBackground = true }; var array1 = new ArrayList { container, store1 }; var array2 = new ArrayList { container, store2 }; lock (container) { thread1.Start(array1); Monitor.Wait(container, 10000); thread2.Start(array2); Monitor.Wait(container, 10000); } Assert.NotSame(array1[1], array2[1]); Assert.Same((array1[1] as SqlServerStore).FileStore as DbDiskCache, (array2[1] as SqlServerStore).FileStore as DbDiskCache); RRContainer.Current = null; }
public IDictionary <Guid, string> GetSavedUrls() { RRTracer.Trace("SqlServerStore Looking for previously saved content."); var files = repository.GetActiveFiles(); return(files.ToDictionary(file => uriBuilder.ParseKey(file), file => uriBuilder.BuildResourceUrl(uriBuilder.ParseKey(file), uriBuilder.ParseSignature(file), RRContainer.GetAllResourceTypes().SingleOrDefault(x => file.EndsWith(x.FileName)).GetType()))); }