public ActionResult Index() { try { _LoggingService.Write("HomeController (Index) page access", true); HomeViewModel vmHome = new HomeViewModel(); _PreferenceRepository.LoadBasePreferences(vmHome); vmHome.ScriptListViewModel.List = _ScriptRepository.GetAll(); vmHome.PlaneListViewModel.List = _PlaneRepository.GetAll(); Execution currentExecution = _ExecutionRepository.GetCurrent(); vmHome.ExecutionViewModel.Current = currentExecution; vmHome.ExecutionViewModel.List = _PlaneRepository.GetPlaneList(currentExecution.ExecutionPlane.ToList()); return(View(vmHome)); } catch (Exception ex) { _LoggingService.WriteWithInner(ex, true, "HomeController(Index) error: "); return(new HttpNotFoundResult()); } }
public void Can_Perform_GetAll_With_Params_On_ScriptRepository() { // 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-script1.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" }; repository.AddOrUpdate(script); var script2 = new Script("test-script2.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" }; repository.AddOrUpdate(script2); var script3 = new Script("test-script3.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" }; repository.AddOrUpdate(script3); unitOfWork.Commit(); // Act var scripts = repository.GetAll("test-script1.js", "test-script2.js"); // Assert Assert.That(scripts, Is.Not.Null); Assert.That(scripts.Any(), Is.True); Assert.That(scripts.Any(x => x == null), Is.False); Assert.That(scripts.Count(), Is.EqualTo(2)); }
/// <summary> /// Returns a list of all objects in the database of a specified resource type. /// </summary> /// <param name="resourceType"></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 List<GameObjectBase> GetAllFromDatabase(GameObjectTypeEnum resourceType, string connectionString = "") { if (resourceType == GameObjectTypeEnum.Area) { using (AreaRepository repo = new AreaRepository(connectionString)) { return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x); } } else if (resourceType == GameObjectTypeEnum.Conversation) { using (ConversationRepository repo = new ConversationRepository(connectionString)) { return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x); } } else if (resourceType == GameObjectTypeEnum.Creature) { using (CreatureRepository repo = new CreatureRepository(connectionString)) { return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x); } } else if (resourceType == GameObjectTypeEnum.Item) { using (ItemRepository repo = new ItemRepository(connectionString)) { return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x); } } else if (resourceType == GameObjectTypeEnum.Placeable) { using (PlaceableRepository repo = new PlaceableRepository(connectionString)) { return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x); } } else if (resourceType == GameObjectTypeEnum.Script) { using (ScriptRepository repo = new ScriptRepository(connectionString)) { return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x); } } else if (resourceType == GameObjectTypeEnum.Tileset) { using (TilesetRepository repo = new TilesetRepository(connectionString)) { return repo.GetAll().ConvertAll<GameObjectBase>(x => (GameObjectBase)x); } } else { throw new NotSupportedException(); } }
public void Can_Perform_GetAll_With_Params_On_ScriptRepository() { // Arrange var provider = new FileUnitOfWorkProvider(); var unitOfWork = provider.GetUnitOfWork(); var repository = new ScriptRepository(unitOfWork, _fileSystem); var script = new Script("test-script1.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" }; repository.AddOrUpdate(script); var script2 = new Script("test-script2.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" }; repository.AddOrUpdate(script2); var script3 = new Script("test-script3.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" }; repository.AddOrUpdate(script3); unitOfWork.Commit(); // Act var scripts = repository.GetAll("test-script1.js", "test-script2.js"); // Assert Assert.That(scripts, Is.Not.Null); Assert.That(scripts.Any(), Is.True); Assert.That(scripts.Any(x => x == null), Is.False); Assert.That(scripts.Count(), Is.EqualTo(2)); }
public void GetAll() { Assert.IsTrue(myScriptRepository.GetAll().Count > 0); }