public void CreateTileCache_ConfigurationDisposed_ThrowObjectDisposedException() { // Setup var configuration = new SimplePersistentCacheConfiguration("path"); configuration.Dispose(); // Call void Call() => configuration.TestCreateTileCache(); // Assert string objectName = Assert.Throws <ObjectDisposedException>(Call).ObjectName; Assert.AreEqual("SimplePersistentCacheConfiguration", objectName); }
public void CreateTileCache_DirectoryNotCreated_CreatesFileCacheDirectoryStructure() { // Setup string rootPath = TestHelper.GetScratchPadPath("CreateTileCache_DirectoryNotCreated_CreatesFileCacheDirectoryStructure"); DoAndCleanupAfter( () => { using (var configuration = new SimplePersistentCacheConfiguration(rootPath)) { // Call IPersistentCache <byte[]> cache = configuration.TestCreateTileCache(); // Assert Assert.IsInstanceOf <FileCache>(cache); Assert.IsTrue(Directory.Exists(rootPath)); } }, rootPath); }
public void CreateTileCache_CreationOfDirectoryNotAllowed_ThrowCannotCreateTileCacheException() { // Setup string rootPath = TestHelper.GetScratchPadPath("CreateTileCache_CreationOfDirectoryNotAllowed_ThrowCannotCreateTileCacheException"); DoAndCleanupAfter( () => { using (var configuration = new SimplePersistentCacheConfiguration(rootPath)) using (new DirectoryPermissionsRevoker(TestHelper.GetScratchPadPath(), FileSystemRights.Write)) { // Call void Call() => configuration.TestCreateTileCache(); // Assert const string expectedMessage = "Een kritieke fout is opgetreden bij het aanmaken van de cache."; string message = Assert.Throws <CannotCreateTileCacheException>(Call).Message; Assert.AreEqual(message, expectedMessage); } }, rootPath); }