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_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 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(); }