public void Wipe() { string testFolder = Path.Join(AppDomain.CurrentDomain.BaseDirectory, this.GetType().Name); if (Directory.Exists(testFolder)) { Directory.Delete(testFolder, true); } Directory.CreateDirectory(testFolder); Core.ITetriSettings settings = new Core.TetriSettings(new TestLogger <Core.TetriSettings>()) { TempPath = Path.Join(testFolder, "Temp") }; Directory.CreateDirectory(settings.TempPath); string testFilePath = Path.Join(settings.TempPath, "test"); File.WriteAllText(testFilePath, string.Empty); Core.ITagsService tagService = new Core.TagsService( settings, new TestLogger <Core.ITagsService>(), new Core.PackageListCache(MemoryCacheHelper.GetInstance())); Core.IIndexReader reader = new Core.IndexReader(settings, new Core.ThreadDefault(), tagService, new TestLogger <Core.IIndexReader>(), new FileSystem(), HashServiceHelper.Instance()); reader.Initialize(); Assert.False(File.Exists(testFilePath)); }
public FileSystemBase() { string testFolder = Path.Join(AppDomain.CurrentDomain.BaseDirectory, this.GetType().Name); if (Directory.Exists(testFolder)) { Directory.Delete(testFolder, true); } Directory.CreateDirectory(testFolder); Settings = new TetriSettings(new TestLogger <TetriSettings>()) { RepositoryPath = Path.Join(testFolder, "repository"), PackagePath = Path.Join(testFolder, "packages"), TempPath = Path.Join(testFolder, "temp"), ArchivePath = Path.Join(testFolder, "archives"), TagsPath = Path.Join(testFolder, "tags") }; Logger = new TestLogger <IIndexReader>(); TagService = new Core.TagsService( Settings, new TestLogger <ITagsService>(), new PackageListCache(MemoryCacheHelper.GetInstance())); IndexReader = new Core.IndexReader(Settings, new Core.ThreadDefault(), TagService, Logger, new FileSystem(), HashServiceHelper.Instance()); Thread.Sleep(200);// fixes race condition when scaffolding up index between consecutive tests IndexReader.Initialize(); }
public Base() { _memoryCache = MemoryCacheHelper.GetInstance(); this.PackageListCache = new PackageListCache(_memoryCache); this.TagsService = new Core.TagsService(this.Settings, new TestLogger <ITagsService>(), this.PackageListCache); this.PackageList = new Core.PackageList(MemoryCacheHelper.GetInstance(), this.Settings, this.TagsService, new TestLogger <IPackageList>()); }
public Base() { _memoryCache = MemoryCacheHelper.GetInstance(); this.PackageListLogger = new TestLogger <IPackageList>(); this.TagServiceLogger = new TestLogger <ITagsService>(); this.PackageListCache = new Core.PackageListCache(_memoryCache); this.TagService = new Core.TagsService(Settings, TagServiceLogger, PackageListCache); this.PackageList = new Core.PackageList(_memoryCache, Settings, TagService, this.PackageListLogger); }
public async Task <List <AspNetMenu> > GetCachedMenus() { var cache = MemoryCacheHelper.GetInstance(); return(await cache.GetOrCreateAsync("AspNetMenu", async entry => { entry.SlidingExpiration = TimeSpan.MaxValue; var menus = await ListAllAsync(); return menus.ToList(); })); }
public void LockedTag() { TestPackage testPackage = PackageHelper.CreatePackage(this.Settings); IMemoryCache _memoryCache = MemoryCacheHelper.GetInstance(); PackageListCache PackageListCache = new PackageListCache(_memoryCache); ITagsService tagsService = new Core.TagsService(this.Settings, new TestLogger <ITagsService>(), PackageListCache); tagsService.AddTag(testPackage.Name, "mytag"); string[] tagDirectories = Directory.GetDirectories(Path.Join(this.Settings.TagsPath)); Assert.Single(tagDirectories); // should be 1 only string[] tagSubscribers = Directory.GetFiles(tagDirectories.First()); Assert.Single(tagSubscribers); // should be 1 only // lock the tag by opening a read stream on it using (new FileStream(tagSubscribers.First(), FileMode.Open, FileAccess.Read, FileShare.Read)) { // no need to assert, this test is for coverage, and all we want is no exception to be thrown here this.IndexReader.DeletePackage(testPackage.Name); } }