public void Can_Perform_Move_On_ScriptRepository() { const string content = "/// <reference name=\"MicrosoftAjax.js\"/>"; // Arrange var provider = new FileUnitOfWorkProvider(Mock.Of<IScopeProvider>()); var unitOfWork = provider.GetUnitOfWork(); var repository = new ScriptRepository(unitOfWork, _fileSystem, Mock.Of<IContentSection>()); var script = new Script("test-move-script.js") { Content = content }; repository.AddOrUpdate(script); unitOfWork.Commit(); // Act script = repository.Get("test-move-script.js"); script.Path = "moved/test-move-script.js"; repository.AddOrUpdate(script); unitOfWork.Commit(); var existsOld = repository.Exists("test-move-script.js"); var existsNew = repository.Exists("moved/test-move-script.js"); script = repository.Get("moved/test-move-script.js"); // Assert Assert.IsNotNull(script); Assert.IsFalse(existsOld); Assert.IsTrue(existsNew); Assert.AreEqual(content, script.Content); }
public void Can_Perform_Exists_On_ScriptRepository() { // Arrange var provider = new FileUnitOfWorkProvider(Mock.Of<IScopeProvider>()); var unitOfWork = provider.GetUnitOfWork(); var repository = new ScriptRepository(unitOfWork, _fileSystem, Mock.Of<IContentSection>()); // Act var exists = repository.Exists("test-script.js"); // Assert Assert.That(exists, Is.True); }
public void Can_Perform_Move_On_ScriptRepository() { const string content = "/// <reference name=\"MicrosoftAjax.js\"/>"; // Arrange var provider = TestObjects.GetScopeProvider(Logger); using (var scope = ScopeProvider.CreateScope()) { var repository = new ScriptRepository(_fileSystems, Mock.Of <IContentSection>()); var script = new Script("test-move-script.js") { Content = content }; repository.Save(script); // Act script = repository.Get("test-move-script.js"); script.Path = "moved/test-move-script.js"; repository.Save(script); var existsOld = repository.Exists("test-move-script.js"); var existsNew = repository.Exists("moved/test-move-script.js"); script = repository.Get("moved/test-move-script.js"); // Assert Assert.IsNotNull(script); Assert.IsFalse(existsOld); Assert.IsTrue(existsNew); Assert.AreEqual(content, script.Content); } }
public void Can_Perform_Exists_On_ScriptRepository() { // Arrange var provider = TestObjects.GetScopeProvider(Logger); using (var scope = ScopeProvider.CreateScope()) { var repository = new ScriptRepository(_fileSystems, Mock.Of <IContentSection>()); // Act var exists = repository.Exists("test-script.js"); // Assert Assert.That(exists, Is.True); } }
public void Can_Perform_Delete_On_ScriptRepository() { // Arrange var provider = new FileUnitOfWorkProvider(Mock.Of<IScopeProvider>()); var unitOfWork = provider.GetUnitOfWork(); var repository = new ScriptRepository(unitOfWork, _fileSystem, Mock.Of<IContentSection>()); // Act var script = repository.Get("test-script.js"); repository.Delete(script); unitOfWork.Commit(); // Assert Assert.IsFalse(repository.Exists("test-script.js")); }
public void Can_Perform_Delete_On_ScriptRepository() { // Arrange var provider = TestObjects.GetScopeProvider(Logger); using (var scope = ScopeProvider.CreateScope()) { var repository = new ScriptRepository(_fileSystems, Mock.Of <IContentSection>()); // Act var script = repository.Get("test-script.js"); repository.Delete(script); // Assert Assert.IsFalse(repository.Exists("test-script.js")); } }
/// <summary> /// Returns True if an object exists in the database. /// Returns False if an object does not exist in the database. /// </summary> /// <param name="resref">The resource reference to search for.</param> /// <param name="resourceType">The resource type to look for.</param> /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param> /// <returns></returns> public bool DoesObjectExistInDatabase(string resref, GameObjectTypeEnum resourceType, string connectionString = "") { if (resourceType == GameObjectTypeEnum.Area) { using (AreaRepository repo = new AreaRepository(connectionString)) { return repo.Exists(resref); } } else if (resourceType == GameObjectTypeEnum.Conversation) { using (ConversationRepository repo = new ConversationRepository(connectionString)) { return repo.Exists(resref); } } else if (resourceType == GameObjectTypeEnum.Creature) { using (CreatureRepository repo = new CreatureRepository(connectionString)) { return repo.Exists(resref); } } else if (resourceType == GameObjectTypeEnum.Item) { using (ItemRepository repo = new ItemRepository(connectionString)) { return repo.Exists(resref); } } else if (resourceType == GameObjectTypeEnum.Placeable) { using (PlaceableRepository repo = new PlaceableRepository(connectionString)) { return repo.Exists(resref); } } else if (resourceType == GameObjectTypeEnum.Script) { using (ScriptRepository repo = new ScriptRepository(connectionString)) { return repo.Exists(resref); } } else if (resourceType == GameObjectTypeEnum.Tileset) { using (TilesetRepository repo = new TilesetRepository(connectionString)) { return repo.Exists(resref); } } else { throw new NotSupportedException(); } }
public void Can_Perform_Exists_On_ScriptRepository() { // Arrange var provider = new FileUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new ScriptRepository(unitOfWork, _fileSystem); // Act var exists = repository.Exists("test-script.js"); // Assert Assert.That(exists, Is.True); }
public void Can_Perform_Delete_On_ScriptRepository() { // Arrange var provider = new FileUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new ScriptRepository(unitOfWork, _fileSystem); // Act var script = repository.Get("test-script.js"); repository.Delete(script); unitOfWork.Commit(); // Assert Assert.IsFalse(repository.Exists("test-script.js")); }