public async Task CS_Cache_Saves()
        {
            // Arrange
            CacheService cache = new CacheService(null, _loggerFactory.CreateLogger <CacheService>());

            // Act
            var filename  = "test.txt";
            var eTag      = "12345";
            var eTagEntry = new FileETag()
            {
                Filename     = filename,
                ETag         = eTag,
                LastModified = new DateTime(1)
            };
            var entries = new List <FileETag>()
            {
                eTagEntry
            };
            var fileContents = @"[" + Environment.NewLine +
                               @"  {" + Environment.NewLine +
                               @"    ""Filename"": ""test.txt""," + Environment.NewLine +
                               @"    ""ETag"": ""12345""," + Environment.NewLine +
                               @"    ""LastModified"": ""0001-01-01T00:00:00.0000001""" + Environment.NewLine +
                               @"  }" + Environment.NewLine +
                               @"]";

            await cache.SaveCacheDataAsync(entries);

            var data = await File.ReadAllTextAsync(Path.Combine(cache.BaseFileDirectory, "FileDownloadCache.json"));


            // Assert
            Assert.IsNotNull(data);
            FileAssert.Exists(Path.Combine(cache.BaseFileDirectory, "FileDownloadCache.json"));
            Assert.AreEqual(fileContents, data);
        }
Beispiel #2
0
 public override int GetHashCode()
 {
     return(FileName != null ? GetType().Name.GetHashCode() ^ FileName.GetHashCode() ^ FileETag.GetHashCode() : 0);
 }