// Update is called once per frame void Update() { ProcessInput(); if (puzzle.IsWin() && !won && !teleportedBack) { puzzle.UpdateWinTargets(); var scene = SceneManager.GetActiveScene(); Analytics.CustomEvent("levelWin", new Dictionary <String, object> { { "level", scene.name }, { "time", simTime }, }); won = true; PersistenceHandler.SetLevelState(SceneManager.GetActiveScene().name, LevelState.Completed); oldPosition = player.transform.position; oldEulerAngles = player.transform.eulerAngles; oldCameraEulerAngles = player.camera.transform.eulerAngles; player.transform.position = new Vector3(-2000, 0, 0); player.transform.eulerAngles = new Vector3(0, 0, 0); player.camera.transform.eulerAngles = new Vector3(0, 0, 0); // TODO: "Next puzzle" button should appear on the navigation menu } }
public void UpdateRequest() { var originalRequest = CreateRequestInRepository(DateTime.Now.Date, "Testdescription", 12.75); var persistentId = originalRequest.PersistentId; PersistenceHandler.ClearReceivedCalls(); var newData = new RequestEntityData { Date = new DateTime(2013, 7, 6), Description = "New Description", Value = 11.11 }; Repository.UpdateRequest(persistentId, newData); var queriedRequest = Repository.QueryRequest(persistentId); Assert.That(queriedRequest.Description, Is.EqualTo("New Description")); Assert.That(queriedRequest.Value, Is.EqualTo(11.11)); PersistenceHandler.Received(1).SaveChanges(Arg.Is <SavingTask>(t => t.RequestsToUpdate.Count == 1 && t.CategoriesToUpdate.Count == 0 && t.EntitiesToDelete.Count == 0 && t.StandingOrdersToUpdate.Count == 0 && t.FilePath == DatabaseFile)); }
/// <summary> /// Opens the Save As dialog, and allow the user to pick the location and name for storing the Kanban Board file /// </summary> private void SaveAsDialog() { _saveAsFileDialog.ShowDialog(); if (_saveAsFileDialog.FileName != "") { _boardFileNameAndPath = _saveAsFileDialog.FileName; PersistenceHandler.Save(_boardContainer, _boardFileNameAndPath); } }
public void Setup() { Context = CreateApplicationContextMockup(true); PersistenceHandler = Substitute.For <DataPersistenceHandler>(); Repository = new RepositoryImp(Context, PersistenceHandler); DatabaseFile = GetUniqueFilePath(true); Repository.Create(DatabaseFile, "DefaultName"); PersistenceHandler.ClearReceivedCalls(); }
/// <summary> /// Saves the board to a file, using the allready set file name and path. /// If it has not been set, it will open the <see cref="SaveAsDialog()"/> /// </summary> private void SaveBoard() { if (_boardFileNameAndPath != null) { PersistenceHandler.Save(_boardContainer, _boardFileNameAndPath); } else { SaveAsDialog(); } }
/// <summary> /// Opens the Load dialog, and allows the user to pick the desired Kanban Board file /// </summary> private void LoadFromDialog() { _openFileDialog.ShowDialog(); if (_openFileDialog.FileName != "") { _boardFileNameAndPath = _openFileDialog.FileName; _boardContainer = PersistenceHandler.Load(_boardFileNameAndPath); ListOfToDo = _boardContainer[0][0].PostItsInCategory; ListOfWorkInProgress = _boardContainer[1][0].PostItsInCategory; ListOfCompletedWork = _boardContainer[2][0].PostItsInCategory; } }
protected CategoryEntityImp[] CreateCategoriesInRepository(int count) { var allCategories = Enumerable.Range(1, count).Select(i => new CategoryEntityImp { Name = "Category" + i }).ToArray(); foreach (var categoryEntityImp in allCategories) { Repository.AddCategory(categoryEntityImp); } PersistenceHandler.ClearReceivedCalls(); return(allCategories); }
public void CreateCategory() { var persistentId = Repository.CreateCategory("My Category"); var createdRequest = Repository.QueryAllCategories().Single(c => c.PersistentId == persistentId); Assert.That(createdRequest.PersistentId, Is.EqualTo(persistentId)); Assert.That(createdRequest.Name, Is.EqualTo("My Category")); PersistenceHandler.Received(1).SaveChanges(Arg.Is <SavingTask>(t => t.RequestsToUpdate.Count == 0 && t.CategoriesToUpdate.Count == 1 && t.EntitiesToDelete.Count == 0 && t.StandingOrdersToUpdate.Count == 0 && t.FilePath == DatabaseFile)); }
public ApplicationContext() { //Setting up asset cache AssetCache.DefaultInstance = new AssetCache(); MessageHub = new TinyMessengerHub(); Scene = new SceneGraph(); Scene.Messenger = MessageHub; SaveLoadHandler = new PersistenceHandler(); //Adding specific persisters SaveLoadHandler.AddPersister(new ScenePersister() { Graph = Scene }); //Set up Engine Engine = new SimulationEngine(Scene); Engine.Messenger = MessageHub; }
public override void FillEntries() { if (inGameMode) { savesList = PersistenceHandler.LoadFromAllFilesInDirectory <TemplateInfo>(PersistenceHandler.gamesDirectory, ".meta"); } else { savesList = PersistenceHandler.LoadFromAllFilesInDirectory <TemplateInfo>(PersistenceHandler.templatesDirectory, ".meta"); } if (savesList != null) { for (int i = 0; i < savesList.Count; i++) { AddEntry(savesList[i]); } } }
public void DeleteSelected() { if (PickedEntry != null) { ModalPanel.Instance().YesNoBox("Confirm deletion", "You are about to delete the save " + PickedEntry.gameNameTxt.text + ". Are you sure?", () => { if (inGameMode) { PersistenceHandler.DeleteFile(PersistenceHandler.gamesDirectory + PickedEntry.gameNameTxt.text + ".xml"); } else { PersistenceHandler.DeleteFile(PersistenceHandler.templatesDirectory + PickedEntry.gameNameTxt.text + ".xml"); } RefillList(); }, null); } }
public void DeleteRequest() { CreateRequestsInRepository(new[] { new DateTime(2014, 1, 1) }, new[] { 10 }); var allRequestIdsBeforeDelete = Repository.QueryRequestsForSingleMonth(2014, 1).Select(r => r.PersistentId).ToArray(); var requestPersistentIdToDelete = allRequestIdsBeforeDelete.First(); Repository.DeleteRequest(requestPersistentIdToDelete); var persistentIdsAfterDelete = Repository.QueryRequestsForSingleMonth(2014, 1).Select(r => r.PersistentId).ToArray(); Assert.That(persistentIdsAfterDelete.Length, Is.EqualTo(9)); CollectionAssert.AreEquivalent(allRequestIdsBeforeDelete.Except(new[] { requestPersistentIdToDelete }), persistentIdsAfterDelete); PersistenceHandler.Received(1).SaveChanges(Arg.Is <SavingTask>(t => t.RequestsToUpdate.Count == 0 && t.CategoriesToUpdate.Count == 0 && t.EntitiesToDelete.Count == 1 && t.StandingOrdersToUpdate.Count == 0 && t.FilePath == DatabaseFile)); }
public void DeleteCategory() { CreateCategoriesInRepository(5); var allCategoryIdsBeforeDelete = Repository.QueryAllCategories().Select(c => c.PersistentId).ToArray(); var categoryPersistentIdToDelete = allCategoryIdsBeforeDelete.First(); Repository.DeleteCategory(categoryPersistentIdToDelete); var persistentIdsAfterDelete = Repository.QueryAllCategories().Select(c => c.PersistentId).ToArray(); Assert.That(persistentIdsAfterDelete.Length, Is.EqualTo(9)); CollectionAssert.AreEquivalent(allCategoryIdsBeforeDelete.Except(new[] { categoryPersistentIdToDelete }), persistentIdsAfterDelete); PersistenceHandler.Received(1).SaveChanges(Arg.Is <SavingTask>(t => t.RequestsToUpdate.Count == 0 && t.CategoriesToUpdate.Count == 0 && t.EntitiesToDelete.Count == 1 && t.StandingOrdersToUpdate.Count == 0 && t.FilePath == DatabaseFile)); }
public void UpdateStandingOrdersToCurrentMonth() { Context.Now.Returns(new DateTime(2015, 8, 6)); var start = Context.Now.AddMonths(-6); Repository.CreateStandingOrder(new StandingOrderEntityData { Description = "Description1", FirstBookDate = start, MonthPeriodStep = 1, ReferenceDay = 6, ReferenceMonth = start.Month, Value = 55.70 }); PersistenceHandler.ClearReceivedCalls(); var requestIds = Repository.UpdateStandingOrdersToCurrentMonth(2015, 8); var requests = Repository.AllRequests.OrderBy(r => r.Date).ToArray(); Assert.That(requests.Length, Is.EqualTo(7)); var monthIndex = 0; foreach (var request in requests) { Assert.That(request.Category, Is.Null); Assert.That(request.Description, Is.EqualTo("Description1")); Assert.That(request.Value, Is.EqualTo(55.70)); Assert.That(request.Date, Is.EqualTo(new DateTime(2015, 2 + monthIndex, 6))); monthIndex++; } PersistenceHandler.Received(1).SaveChanges(Arg.Is <SavingTask>(t => t.RequestsToUpdate.Count == 7 && t.CategoriesToUpdate.Count == 0 && t.EntitiesToDelete.Count == 0 && t.StandingOrdersToUpdate.Count == 1 && t.FilePath == DatabaseFile)); Assert.That(requestIds.Length, Is.EqualTo(7)); CollectionAssert.AreEquivalent(requestIds, requests.Select(r => r.PersistentId).ToArray()); }
public void UpdateCategory() { var originalCategory = new CategoryEntityImp { Name = "Category" }; var persistentId = originalCategory.PersistentId; Repository.AddCategory(originalCategory); Repository.UpdateCategory(persistentId, "New Category Name"); var categoryQueried = Repository.QueryCategory(persistentId); Assert.That(categoryQueried.PersistentId, Is.EqualTo(persistentId)); Assert.That(categoryQueried.Name, Is.EqualTo("New Category Name")); PersistenceHandler.Received(1).SaveChanges(Arg.Is <SavingTask>(t => t.RequestsToUpdate.Count == 0 && t.CategoriesToUpdate.Count == 1 && t.EntitiesToDelete.Count == 0 && t.StandingOrdersToUpdate.Count == 0 && t.FilePath == DatabaseFile)); }
public void CreateRequest(bool withCategory) { CreateCategoriesInRepository(3); CreateRequestsInRepository(new[] { new DateTime(2014, 1, 1) }, new[] { 10 }); var categoryEntity = Repository.QueryAllCategories().First(); var requestData = new RequestEntityData { Date = new DateTime(2014, 6, 1), Description = "My Description", Value = -11, CategoryPersistentId = withCategory ? categoryEntity.PersistentId : null }; PersistenceHandler.ClearReceivedCalls(); var persistentId = Repository.CreateRequest(requestData); var createdRequest = Repository.QueryRequest(persistentId); Assert.That(createdRequest.PersistentId, Is.EqualTo(persistentId)); Assert.That(createdRequest.Description, Is.EqualTo(requestData.Description)); Assert.That(createdRequest.Value, Is.EqualTo(requestData.Value)); if (withCategory) { Assert.That(createdRequest.Category.PersistentId, Is.EqualTo(categoryEntity.PersistentId)); } else { Assert.That(createdRequest.Category, Is.Null); } PersistenceHandler.Received(1).SaveChanges(Arg.Is <SavingTask>(t => t.RequestsToUpdate.Count == 1 && t.CategoriesToUpdate.Count == 0 && t.EntitiesToDelete.Count == 0 && t.StandingOrdersToUpdate.Count == 0 && t.FilePath == DatabaseFile)); }
public void DeleteCategoryReferencedByRequestRemovesCategoryFromRequest() { var category = new CategoryEntityImp { Name = "My Category" }; Repository.AddCategory(category); var request = CreateRequestInRepository(DateTime.Now, "Test", 12.0); request.Category = category; PersistenceHandler.ClearReceivedCalls(); Repository.DeleteCategory(category.PersistentId); Assert.That(request.Category, Is.Null); PersistenceHandler.Received(1).SaveChanges(Arg.Is <SavingTask>(t => t.RequestsToUpdate.Count == 1 && t.CategoriesToUpdate.Count == 0 && t.EntitiesToDelete.Count == 1 && t.StandingOrdersToUpdate.Count == 0 && t.FilePath == DatabaseFile)); }
// Initializes the button with the appropriate level. public void Setup(string level) { this.level = level; levelLabel.text = level; this.hideAllIcons(); switch (PersistenceHandler.GetLevelState(level)) { case LevelState.New: break; case LevelState.Visited: // TODO break; case LevelState.Completed: levelStateCompletedIcon.enabled = true; break; default: break; } }
static int Main(string[] args) { Console.WriteLine("My.Data.Bandwidth Initialising..."); var arguments = args.Select(x => x.ToLower()).ToList(); var test = new SpeedTestHandler(); var persist = new PersistenceHandler <SpeedTestDataModel>(); var httpClientFactory = new ServiceCollection() .AddHttpClient() .BuildServiceProvider() .GetService <IHttpClientFactory>(); var transmit = new TransmitHandler <SpeedTestDataModel>(httpClientFactory); var announce = new ConsoleOutputHandler <SpeedTestDataModel>(); var process = new ResultHandler <SpeedTestDataModel>(); var success = true; Console.WriteLine("My.Data.Bandwidth Starting..."); while (success) { var result = test.Execute(DateTimeOffset.UtcNow).GetAwaiter().GetResult(); // abort on error if instructed, else continue forever if ( arguments.Any() && arguments.Contains("abortonerror") && result.IsError) { // error and exit success = !result.IsError; persist.Execute(result).Wait(); bool transmitViaAPI = false; // TODO via settings if (transmitViaAPI) { transmit.Execute(result).Wait(); } announce.Execute(result).Wait(); } else if (result.IsError) { // error and repeat persist.Execute(result).Wait(); bool transmitViaAPI = false; // TODO via settings if (transmitViaAPI) { transmit.Execute(result).Wait(); } announce.Execute(result).Wait(); } else { // all is well persist.Execute(result).Wait(); bool transmitViaAPI = false; // TODO via settings if (transmitViaAPI) { transmit.Execute(result).Wait(); } announce.Execute(result).Wait(); process.Execute(result).Wait(); } } return(1); // always returns an error - because it should run forever. }
public DbOperations(IReplicaSynchronizationService dataSynchronizer, PersistenceHandler persistenceHandler) { _dataSynchronizer = dataSynchronizer; _persistenceHandler = persistenceHandler; }