public async Task When_GetGameDataAndStoreInLocalDb_is_called_should_create_Puzzle_db_file_in_location_provided() { IPuzzleWebApiService puzzleWebApiService = new FakePuzzleWebApiService(); IGameDataService gameDataService = new GameDataService(puzzleWebApiService,null); string path = ApplicationData.Current.TemporaryFolder.Path; Task resultTask = gameDataService.GetGameDataAndStoreInLocalDb(ApplicationData.Current.TemporaryFolder.Path); await resultTask; bool fileExists = await FileExistInStorageLocation(path, "Puzzle.db"); Assert.IsTrue(fileExists); }
public async Task When_GetPuzzleById_is_called_on_the_Repository_Should_return_the_puzzle_with_said_id() { string path = ApplicationData.Current.TemporaryFolder.Path; IPuzzleWebApiService puzzleWebApiService = new FakePuzzleWebApiService(); IGameDataService gameDataService = new GameDataService(puzzleWebApiService,null); Task resultTask = gameDataService.GetGameDataAndStoreInLocalDb(ApplicationData.Current.TemporaryFolder.Path); await resultTask; IPuzzleRepository puzzleRepository = new PuzzleRepository(); puzzleRepository.AddPuzzleRepositoryPath(ApplicationData.Current.TemporaryFolder.Path); var result = puzzleRepository.GetPuzzleWithId(1, "Abdul"); Assert.AreEqual("Confectioner", result.FirstOrDefault().Key); }
public async Task Should_load_up_create_puzzle_db_file_and_load_up_new_word_list() { IPuzzleWebApiService puzzleWebApiService = new FakePuzzleWebApiService(); IGameDataService gameDataService = new GameDataService(puzzleWebApiService,new PuzzlesService(new PuzzleRepository(), new UserService())); var packagePath = Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, "NewWords"); string path = ApplicationData.Current.TemporaryFolder.Path; await gameDataService.ProcessNewWordsIfAny(packagePath,path); bool fileExists = await FileExistInStorageLocation(path, "Puzzle.db"); var rows = 0; using (var db = new SQLiteConnection(Path.Combine(path, "Puzzle.db"))) { rows = db.Table<PuzzleGroupData>().Count(); } Assert.IsTrue(rows > 0); }