public void Test_Store_Same_entry_With_Versions() { // create storage FileCacheStorage storage = new FileCacheStorage(_curDir, _curFile, _fileSystemMock.Object, _serializerMock.Object); string id = "1"; string version1 = "1.1"; string version2 = "2.0"; // store the data with id and version1 storage.Set(_data, id, version1); // store the data with id and version2 storage.Set(_data, id, version2); // check version of the FileCacheEntry with id in the storage Assert.AreEqual(true, storage.Has(id)); Assert.AreEqual(true, storage.MatchesVersion(id, version2)); Assert.AreEqual(false, storage.MatchesVersion(id, version1)); string version3 = "3.0"; // store the data with id and version3 storage.Set(_data, id, version3); // check version of the FileCacheEntry with id in the storage Assert.AreEqual(true, storage.MatchesVersion(id, version3)); }
public void Store_Empty_Id() { FileCacheStorage storage = new FileCacheStorage(_curDir, _curFile, _fileSystemMock.Object, _serializerMock.Object); // test limits // store data with empty id storage.Set(_data, ""); // store empty data with empty id storage.Set(new byte[0], ""); storage.SaveCacheStorageFile(); // check FileCacheEntry count Assert.AreEqual(1, storage.CacheEntries.Count); }
public void Dir_Exist_File_Exist_And_Corrupted_Store_And_Delete_Entry() { // define: directory - exist, file - exist, but corrupted setupMocks(true); FileCacheStorage storage = new FileCacheStorage(_curDir, _curFile, _fileSystemMock.Object, _serializerMock.Object); // store 2 FileCacheEntry string id1 = "1"; string id2 = "2"; storage.Set(_data, id1); storage.Set(_data, id2); // check FileCacheEntry numbers storage.SaveCacheStorageFile(); Assert.AreEqual(2, storage.CacheEntries.Count); // delete "1" FileCacheEntry storage.Delete(id1); // check FileCacheEntry numbers storage.SaveCacheStorageFile(); Assert.AreEqual(1, storage.CacheEntries.Count); }
private FileCacheStorage createAndFillStorage(int entriesNumber, string version = "") { setupMocks(); FileCacheStorage storage = new FileCacheStorage(_curDir, _curFile, _fileSystemMock.Object, _serializerMock.Object); for (int ii = 0; ii < entriesNumber; ii++) { string id = (ii + 1).ToString(); storage.Set(_data, id, version); } return(storage); }
public void Test_CheckVersioning() { string version1 = "1.1"; FileCacheStorage storage = createAndFillStorage(4, version1); string id = "1"; string version2 = "2.0"; // change version for id storage.Set(_data2, id, version2); // check if version changed Assert.AreEqual(true, storage.MatchesVersion(id, version2)); // check old version Assert.AreEqual(false, storage.MatchesVersion(id, version1)); }