public void InitializeFromTileSource_ConfigurationDisposed_ThrowObjectDisposedException() { // Setup var mocks = new MockRepository(); var tileProvider = mocks.Stub <ITileProvider>(); var tileSchema = mocks.Stub <ITileSchema>(); mocks.ReplayAll(); string rootPath = TestHelper.GetScratchPadPath("InitializeFromTileSource_ConfigurationDisposed_ThrownObjectDisposedException"); var configuration = new SimplePersistentCacheConfiguration(rootPath); configuration.Dispose(); var tileSource = new TileSource(tileProvider, tileSchema); DoAndCleanupAfter( () => { // Call void Call() => configuration.TestInitializeFromTileSource(tileSource); // Assert string objectName = Assert.Throws <ObjectDisposedException>(Call).ObjectName; Assert.AreEqual("SimplePersistentCacheConfiguration", objectName); }, rootPath); mocks.VerifyAll(); }
public void TestInitializeFromTileSource_CreationOfDirectoryNotAllowed_ThrowCannotCreateTileCacheException() { // Setup var mocks = new MockRepository(); var tileProvider = mocks.Stub <ITileProvider>(); var tileSchema = mocks.Stub <ITileSchema>(); mocks.ReplayAll(); var tileSource = new TileSource(tileProvider, tileSchema); string rootPath = TestHelper.GetScratchPadPath("TestInitializeFromTileSource_CreationOfDirectoryNotAllowed_ThrowCannotCreateTileCacheException"); DoAndCleanupAfter( () => { using (var configuration = new SimplePersistentCacheConfiguration(rootPath)) using (new DirectoryPermissionsRevoker(TestHelper.GetScratchPadPath(), FileSystemRights.Write)) { // Call void Call() => configuration.TestInitializeFromTileSource(tileSource); // 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); }
public void InitializeFromTileSource_ValidTileSource_InitializeConfiguration() { // Setup var mocks = new MockRepository(); var tileProvider = mocks.Stub <ITileProvider>(); var tileSchema = mocks.Stub <ITileSchema>(); mocks.ReplayAll(); string rootPath = TestHelper.GetScratchPadPath("InitializeFromTileSource_ValidTileSource_InitializeConfiguration"); DoAndCleanupAfter( () => { using (var configuration = new SimplePersistentCacheConfiguration(rootPath)) { var tileSource = new TileSource(tileProvider, tileSchema); // Call configuration.TestInitializeFromTileSource(tileSource); // Assert Assert.AreSame(tileSource.Schema, configuration.TileSchema); Assert.IsInstanceOf <AsyncTileFetcher>(configuration.TileFetcher); Assert.IsTrue(configuration.Initialized); } }, rootPath); mocks.VerifyAll(); }
public void Constructor_ExpectedValues() { // Call using (var configuration = new SimplePersistentCacheConfiguration("folder")) { // Assert Assert.IsInstanceOf <IConfiguration>(configuration); Assert.IsFalse(configuration.Initialized); Assert.IsNull(configuration.TileSchema); Assert.IsNull(configuration.TileFetcher); } }
public void Dispose_CalledMultipleTimes_DoesNotThrow() { // Setup var configuration = new SimplePersistentCacheConfiguration("folder"); // Call void Call() { configuration.Dispose(); configuration.Dispose(); } // Assert Assert.DoesNotThrow(Call); }
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); }