public async Task AssignmentSavedInAssignmentManagingPageTest() { var _azureService = new MockAzureService(); var _navigationService = new MockNavigationService(); var app = new App(_azureService); var viewModel = new AssignmentManagingPageViewModel(_navigationService, null); await _azureService.SyncOfflineCacheAsync(); var assignment = (await(await _azureService.GetTableAsync <Assignment>()) .Where(s => s.Name == "Assignment1")) .FirstOrDefault(); var navigationParams = new NavigationParameters { { "model", assignment } }; viewModel.OnNavigatingTo(navigationParams); viewModel.Assignment.Name = "AssignmentChanged"; viewModel.SaveAssignmentCommand.Execute(); var assignmentAfter = (await(await _azureService.GetTableAsync <Assignment>()) .Where(s => s.Name == "AssignmentChanged")) .FirstOrDefault(); Assert.IsNotNull(assignmentAfter); }
public async Task ExercisesNotNullAfterAssignmentManagingPageNavigatedToTest() { var _azureService = new MockAzureService(); var app = new App(_azureService); var viewModel = new AssignmentManagingPageViewModel(null, null); await _azureService.SyncOfflineCacheAsync(); var assignment = (await(await _azureService.GetTableAsync <Assignment>()) .Where(s => s.Name == "Assignment1")) .FirstOrDefault(); var navigationParams = new NavigationParameters { { "model", assignment } }; viewModel.OnNavigatingTo(navigationParams); Assert.NotNull(viewModel.Exercises); }
public async Task ExerciseDeletedInAssignmentExercisesPageTest() { var _azureService = new MockAzureService(); var _pageDialogService = new MockPageDialogService(); var app = new App(_azureService); var viewModel = new AssignmentManagingPageViewModel(null, _pageDialogService); await _azureService.SyncOfflineCacheAsync(); var assignment = (await(await _azureService.GetTableAsync <Assignment>()) .Where(s => s.Name == "Assignment1")) .FirstOrDefault(); var navigationParams = new NavigationParameters { { "model", assignment } }; viewModel.OnNavigatingTo(navigationParams); var exercisesBefore = (await(await _azureService.GetTableAsync <Exercise>()) .Where(s => s.Assignment_Id == assignment.Id)) .Count; var exercise = (await(await _azureService.GetTableAsync <Exercise>()) .Where(s => s.Word == "WordOne")) .FirstOrDefault(); viewModel.DeleteExerciseCommand.Execute(exercise); var exercisesAfter = (await(await _azureService.GetTableAsync <Exercise>()) .Where(s => s.Assignment_Id == assignment.Id)) .Count; Assert.IsTrue(exercisesAfter == exercisesBefore - 1 && viewModel.Exercises.Count == exercisesAfter); }