Ejemplo n.º 1
0
        public override void InstallBindings()
        {
            const string CacheDirName       = "planet_cache";
            var          cachePathGenerator = new CachePathGenerator(CacheDirName);
            var          imageDownloader    = new CachedImageDownloader(cachePathGenerator);
            var          imageLoader        = new CachedImageLoader(imageDownloader);

            Container.Bind <IImageLoader>().FromInstance(imageLoader);
        }
Ejemplo n.º 2
0
        public void CacheFilePathEquality()
        {
            var cachePathGenerator = new CachePathGenerator($"test-{Guid.NewGuid():N}");
            var imageUrl           = "https://sample-videos.com/img/Sample-jpg-image-50kb.jpg";

            Assert.AreEqual(
                cachePathGenerator.GenerateCachePath(imageUrl),
                cachePathGenerator.GenerateCachePath(imageUrl),
                "Different cache file path returned for equivalent inputs");
        }
Ejemplo n.º 3
0
        public void CacheFileReadWrite()
        {
            var cachePathGenerator = new CachePathGenerator($"test-{Guid.NewGuid():N}");
            var imageUrl           = "https://sample-videos.com/img/Sample-jpg-image-50kb.jpg";
            var cachePath          = cachePathGenerator.GenerateCachePath(imageUrl);

            Directory.CreateDirectory(cachePathGenerator.DirPath);
            File.WriteAllBytes(cachePath, new byte[] { 0 });

            Assert.IsTrue(File.Exists(cachePath));
        }
Ejemplo n.º 4
0
        async UniTask DoDownloadImageCaching()
        {
            var cachePathGenerator = new CachePathGenerator($"test-{Guid.NewGuid():N}");
            var imageDownloader    = new CachedImageDownloader(cachePathGenerator);
            var imageUrl           = "https://sample-videos.com/img/Sample-jpg-image-50kb.jpg";

            var texture = await imageDownloader.Download(imageUrl);

            var textureCached = await imageDownloader.Download(imageUrl);

            Assert.IsFalse(texture.GetPixels().SequenceEqual(textureCached.GetPixels()));
        }