From 888d4dee3e8afdc228838bef984315fe16844e46 Mon Sep 17 00:00:00 2001 From: HarelM Date: Wed, 29 May 2024 12:00:53 +0300 Subject: [PATCH] Remove mbtiles & sqlite --- .../Controllers/FilesController.cs | 7 +- .../Services/IOfflineFilesService.cs | 3 +- .../Services/OfflineFilesService.cs | 4 +- IsraelHiking.Web/package-lock.json | 77 +------------ IsraelHiking.Web/package.json | 4 +- .../src/application/application.module.ts | 2 - .../application/services/database.service.ts | 15 +-- .../services/elevation.provider.ts | 6 +- .../application/services/mbtiles.service.ts | 109 ------------------ .../application/services/routing.provider.ts | 6 +- .../Controllers/FilesControllerTests.cs | 8 +- .../Services/OfflineFilesServiceTests.cs | 6 +- 12 files changed, 27 insertions(+), 220 deletions(-) delete mode 100644 IsraelHiking.Web/src/application/services/mbtiles.service.ts diff --git a/IsraelHiking.API/Controllers/FilesController.cs b/IsraelHiking.API/Controllers/FilesController.cs index fff67ff7a..8f43a7387 100644 --- a/IsraelHiking.API/Controllers/FilesController.cs +++ b/IsraelHiking.API/Controllers/FilesController.cs @@ -120,20 +120,19 @@ private async Task ConvertToDataContainer(byte[] data, string /// Get a list of files that need to be downloaded since they are out dated /// /// - /// This parameter was added in 1.2024 /// [HttpGet] [Route("offline")] [Authorize] - public async Task GetOfflineFiles([FromQuery] DateTime lastModified, [FromQuery] bool pmtiles) + public async Task GetOfflineFiles([FromQuery] DateTime lastModified) { if (!await _receiptValidationGateway.IsEntitled(User.Identity?.Name)) { _logger.LogInformation($"Unable to get the list of offline files for user: {User.Identity?.Name} since the user is not entitled, date: {lastModified}"); return Forbid(); } - _logger.LogInformation($"Getting the list of offline files for user: {User.Identity?.Name}, date: {lastModified}, pmtiles: {pmtiles}"); - return Ok(_offlineFilesService.GetUpdatedFilesList(lastModified, pmtiles)); + _logger.LogInformation($"Getting the list of offline files for user: {User.Identity?.Name}, date: {lastModified}"); + return Ok(_offlineFilesService.GetUpdatedFilesList(lastModified)); } /// diff --git a/IsraelHiking.API/Services/IOfflineFilesService.cs b/IsraelHiking.API/Services/IOfflineFilesService.cs index 55452d6d2..5efe28d86 100644 --- a/IsraelHiking.API/Services/IOfflineFilesService.cs +++ b/IsraelHiking.API/Services/IOfflineFilesService.cs @@ -20,8 +20,7 @@ public interface IOfflineFilesService /// Get a list of files that have been updated since a given date /// /// The date to check against - /// /// A list of file names - Dictionary GetUpdatedFilesList(DateTime lastModifiedDate, bool pmtiles); + Dictionary GetUpdatedFilesList(DateTime lastModifiedDate); } } \ No newline at end of file diff --git a/IsraelHiking.API/Services/OfflineFilesService.cs b/IsraelHiking.API/Services/OfflineFilesService.cs index b6d10990c..1fec65892 100644 --- a/IsraelHiking.API/Services/OfflineFilesService.cs +++ b/IsraelHiking.API/Services/OfflineFilesService.cs @@ -37,7 +37,7 @@ public OfflineFilesService(IFileSystemHelper fileSystemHelper, } /// - public Dictionary GetUpdatedFilesList(DateTime lastModifiedDate, bool pmtiles) + public Dictionary GetUpdatedFilesList(DateTime lastModifiedDate) { var filesDictionary = new Dictionary(); var contents = _fileProvider.GetDirectoryContents(string.Empty); @@ -51,7 +51,7 @@ public Dictionary GetUpdatedFilesList(DateTime lastModifiedDat { continue; } - if (content.Name.EndsWith(pmtiles ? ".pmtiles" : ".mbtiles") || content.Name.StartsWith("style")) + if (content.Name.EndsWith(".pmtiles") || content.Name.StartsWith("style")) { filesDictionary[content.Name] = content.LastModified.DateTime; } diff --git a/IsraelHiking.Web/package-lock.json b/IsraelHiking.Web/package-lock.json index 251ffd28a..f77863226 100644 --- a/IsraelHiking.Web/package-lock.json +++ b/IsraelHiking.Web/package-lock.json @@ -25,7 +25,6 @@ "@awesome-cordova-plugins/social-sharing": "^6.7.0", "@capacitor-community/keep-awake": "^5.0.0", "@capacitor-community/screen-brightness": "^6.0.0", - "@capacitor-community/sqlite": "^5.7.3-3", "@capacitor/android": "^6.0.0", "@capacitor/app": "^6.0.0", "@capacitor/camera": "^6.0.0", @@ -68,7 +67,7 @@ "d3": "^7.9.0", "d3-regression": "^1.3.10", "deepmerge": "^4.3.1", - "dexie": "^3.2.6", + "dexie": "^4.0.7", "fflate": "^0.8.2", "file-saver-es": "^2.0.5", "font-awesome": "^4.7.0", @@ -77,6 +76,7 @@ "intl": "^1.2.5", "invert-color": "^2.0.0", "isomorphic-xml2js": "^0.1.3", + "jszip": "^3.10.1", "linear-interpolator": "^1.0.2", "lodash-es": "^4.17.21", "lottie-web": "^5.12.2", @@ -2719,20 +2719,6 @@ "@capacitor/core": "^6.0.0" } }, - "node_modules/@capacitor-community/sqlite": { - "version": "5.7.3-3", - "resolved": "https://registry.npmjs.org/@capacitor-community/sqlite/-/sqlite-5.7.3-3.tgz", - "integrity": "sha512-vVOLzQi34zi7a2+FnTQm0KfXdno4Q1236fWHtC3+HaOFfdn6kV1S6p67DEbixLmxivYSxzy1oyyFUY6tVIdlXw==", - "dependencies": { - "jeep-sqlite": "^2.7.0" - }, - "engines": { - "node": ">=16.0.0" - }, - "peerDependencies": { - "@capacitor/core": "^5.0.0" - } - }, "node_modules/@capacitor/android": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/@capacitor/android/-/android-6.0.0.tgz", @@ -5611,18 +5597,6 @@ "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==", "dev": true }, - "node_modules/@stencil/core": { - "version": "4.18.3", - "resolved": "https://registry.npmjs.org/@stencil/core/-/core-4.18.3.tgz", - "integrity": "sha512-8yoG5AFQYEPocVtuoc5kvRS0Hku0MoDWDUpADRaXPVHsOFLmxR16LJENj25ucCz5GEfeTGQ/tCE8JAypPmr/fQ==", - "bin": { - "stencil": "bin/stencil" - }, - "engines": { - "node": ">=16.0.0", - "npm": ">=7.10.0" - } - }, "node_modules/@tufjs/canonical-json": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@tufjs/canonical-json/-/canonical-json-2.0.0.tgz", @@ -7935,11 +7909,6 @@ "node": ">=6.9.0" } }, - "node_modules/browser-fs-access": { - "version": "0.35.0", - "resolved": "https://registry.npmjs.org/browser-fs-access/-/browser-fs-access-0.35.0.tgz", - "integrity": "sha512-sLoadumpRfsjprP8XzVjpQc0jK8yqHBx0PtUTGYj2fftT+P/t+uyDAQdMgGAPKD011in/O+YYGh7fIs0oG/viw==" - }, "node_modules/browserslist": { "version": "4.23.0", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz", @@ -9645,12 +9614,9 @@ "dev": true }, "node_modules/dexie": { - "version": "3.2.7", - "resolved": "https://registry.npmjs.org/dexie/-/dexie-3.2.7.tgz", - "integrity": "sha512-2a+BXvVhY5op+smDRLxeBAivE7YcYaneXJ1la3HOkUfX9zKkE/AJ8CNgjiXbtXepFyFmJNGSbmjOwqbT749r/w==", - "engines": { - "node": ">=6.0" - } + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/dexie/-/dexie-4.0.7.tgz", + "integrity": "sha512-M+Lo6rk4pekIfrc2T0o2tvVJwL6EAAM/B78DNfb8aaxFVoI1f8/rz5KTxuAnApkwqTSuxx7T5t0RKH7qprapGg==" }, "node_modules/di": { "version": "0.0.1", @@ -13058,18 +13024,6 @@ "colors": "1.4.0" } }, - "node_modules/jeep-sqlite": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/jeep-sqlite/-/jeep-sqlite-2.7.1.tgz", - "integrity": "sha512-B2ieO83pCkT8HvWuvqwwTa29bx6pRGmdD0ry3oPvL7QRBOVZ6ZUSkhaf+5e7gtunD8wzBxbZwNCiWRZnwgmlaA==", - "dependencies": { - "@stencil/core": "^4.15.0", - "browser-fs-access": "^0.35.0", - "jszip": "^3.10.1", - "localforage": "^1.10.0", - "sql.js": "^1.10.3" - } - }, "node_modules/jest-diff": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.7.0.tgz", @@ -13834,22 +13788,6 @@ "node": ">= 12.13.0" } }, - "node_modules/localforage": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz", - "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==", - "dependencies": { - "lie": "3.1.1" - } - }, - "node_modules/localforage/node_modules/lie": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", - "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==", - "dependencies": { - "immediate": "~3.0.5" - } - }, "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -18164,11 +18102,6 @@ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, - "node_modules/sql.js": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/sql.js/-/sql.js-1.10.3.tgz", - "integrity": "sha512-H46aWtQkdyjZwFQgraUruy5h/DyJBbAK3EA/WEMqiqF6PGPfKBSKBj/er3dVyYqVIoYfRf5TFM/loEjtQIrqJg==" - }, "node_modules/ssri": { "version": "10.0.6", "resolved": "https://registry.npmjs.org/ssri/-/ssri-10.0.6.tgz", diff --git a/IsraelHiking.Web/package.json b/IsraelHiking.Web/package.json index c28267d3c..f17e2e437 100644 --- a/IsraelHiking.Web/package.json +++ b/IsraelHiking.Web/package.json @@ -16,7 +16,6 @@ "@awesome-cordova-plugins/social-sharing": "^6.7.0", "@capacitor-community/keep-awake": "^5.0.0", "@capacitor-community/screen-brightness": "^6.0.0", - "@capacitor-community/sqlite": "^5.7.3-3", "@capacitor/android": "^6.0.0", "@capacitor/app": "^6.0.0", "@capacitor/camera": "^6.0.0", @@ -59,7 +58,7 @@ "d3": "^7.9.0", "d3-regression": "^1.3.10", "deepmerge": "^4.3.1", - "dexie": "^3.2.6", + "dexie": "^4.0.7", "fflate": "^0.8.2", "file-saver-es": "^2.0.5", "font-awesome": "^4.7.0", @@ -68,6 +67,7 @@ "intl": "^1.2.5", "invert-color": "^2.0.0", "isomorphic-xml2js": "^0.1.3", + "jszip": "^3.10.1", "linear-interpolator": "^1.0.2", "lodash-es": "^4.17.21", "lottie-web": "^5.12.2", diff --git a/IsraelHiking.Web/src/application/application.module.ts b/IsraelHiking.Web/src/application/application.module.ts index b1b8bcf30..5c0c9d11f 100644 --- a/IsraelHiking.Web/src/application/application.module.ts +++ b/IsraelHiking.Web/src/application/application.module.ts @@ -96,7 +96,6 @@ import { GlobalErrorHandler } from "./services/global-error.handler"; import { OverpassTurboService } from "./services/overpass-turbo.service"; import { ImageAttributionService } from "./services/image-attribution.service"; import { PmTilesService } from "./services/pmtiles.service"; -import { MBTilesService } from "./services/mbtiles.service"; // interactions import { RouteEditPoiInteraction } from "./components/intercations/route-edit-poi.interaction"; import { RouteEditRouteInteraction } from "./components/intercations/route-edit-route.interaction"; @@ -310,7 +309,6 @@ const initializeApplication = (injector: Injector) => async () => { OverpassTurboService, ImageAttributionService, PmTilesService, - MBTilesService, AudioPlayerFactory, FileSystemWrapper, // eslint-disable-next-line diff --git a/IsraelHiking.Web/src/application/services/database.service.ts b/IsraelHiking.Web/src/application/services/database.service.ts index 463c5d621..f87cf13e6 100644 --- a/IsraelHiking.Web/src/application/services/database.service.ts +++ b/IsraelHiking.Web/src/application/services/database.service.ts @@ -8,7 +8,6 @@ import deepmerge from "deepmerge"; import { LoggingService } from "./logging.service"; import { RunningContextService } from "./running-context.service"; import { PmTilesService } from "./pmtiles.service"; -import { MBTilesService } from "./mbtiles.service"; import { POPULARITY_HEATMAP, initialState } from "../reducers/initial-state"; import { ClearHistoryAction } from "../reducers/routes.reducer"; import { SetSelectedPoiAction, SetSidebarAction } from "../reducers/poi.reducer"; @@ -46,13 +45,11 @@ export class DatabaseService { constructor(private readonly loggingService: LoggingService, private readonly runningContext: RunningContextService, private readonly pmTilesService: PmTilesService, - private readonly mbtilesService: MBTilesService, private readonly store: Store) { this.updating = false; } public async initialize() { - this.mbtilesService.initialize(); this.stateDatabase = new Dexie(DatabaseService.STATE_DB_NAME); this.stateDatabase.version(1).stores({ state: "id" @@ -101,7 +98,7 @@ export class DatabaseService { private initCustomTileLoadFunction() { addProtocol("custom", async (params, _abortController) => { - const data = await this.getTile(params.url); + const data = await this.pmTilesService.getTile(params.url); return {data}; }); } @@ -113,7 +110,6 @@ export class DatabaseService { this.store.dispatch(new SetSidebarAction(false)); const finalState = this.store.snapshot() as ApplicationState; await this.updateState(finalState); - await this.mbtilesService.uninitialize(); } private async updateState(state: ApplicationState) { @@ -133,15 +129,6 @@ export class DatabaseService { } } - public async getTile(url: string): Promise { - try { - return await this.pmTilesService.getTile(url); - } catch (ex) { - this.loggingService.error(`[Database] Failed to get tile from pmtiles: ${(ex as Error).message}`); - } - return this.mbtilesService.getTile(url); - } - public storePois(pois: GeoJSON.Feature[]): Promise { return this.poisDatabase.table(DatabaseService.POIS_TABLE_NAME).bulkPut(pois); } diff --git a/IsraelHiking.Web/src/application/services/elevation.provider.ts b/IsraelHiking.Web/src/application/services/elevation.provider.ts index 448d9ddae..22f0d25fb 100644 --- a/IsraelHiking.Web/src/application/services/elevation.provider.ts +++ b/IsraelHiking.Web/src/application/services/elevation.provider.ts @@ -6,7 +6,7 @@ import { firstValueFrom } from "rxjs"; import { LoggingService } from "./logging.service"; import { SpatialService } from "./spatial.service"; -import { DatabaseService } from "./database.service"; +import { PmTilesService } from "./pmtiles.service"; import { Urls } from "../urls"; import type { ApplicationState, LatLngAlt } from "../models/models"; @@ -20,7 +20,7 @@ export class ElevationProvider { constructor(private readonly httpClient: HttpClient, private readonly loggingService: LoggingService, - private readonly databaseService: DatabaseService, + private readonly pmTilesService: PmTilesService, private readonly store: Store) { this.elevationCache = new Map(); } @@ -95,7 +95,7 @@ export class ElevationProvider { continue; } - const arrayBuffer = await this.databaseService.getTile(`custom://TerrainRGB/${zoom}/${tileX}/${tileY}.png`); + const arrayBuffer = await this.pmTilesService.getTile(`custom://TerrainRGB/${zoom}/${tileX}/${tileY}.png`); const data = await this.getImageData(arrayBuffer); this.elevationCache.set(key, data); } diff --git a/IsraelHiking.Web/src/application/services/mbtiles.service.ts b/IsraelHiking.Web/src/application/services/mbtiles.service.ts deleted file mode 100644 index 38100337a..000000000 --- a/IsraelHiking.Web/src/application/services/mbtiles.service.ts +++ /dev/null @@ -1,109 +0,0 @@ -import { Injectable } from "@angular/core"; -import { gunzipSync } from "fflate"; - -import { CapacitorSQLite, SQLiteDBConnection, SQLiteConnection} from "@capacitor-community/sqlite"; -import { RunningContextService } from "./running-context.service"; -import { LoggingService } from "./logging.service"; - -// HM TODO: remove this class in 6.2024 and all code related to sqlite -@Injectable() -export class MBTilesService { - private sourceDatabases: Map>; - private sqlite: SQLiteConnection; - - constructor(private readonly runningContext: RunningContextService, - private readonly loggingService: LoggingService) { - this.sourceDatabases = new Map>(); - } - - public initialize() { - if (this.runningContext.isCapacitor) { - this.sqlite = new SQLiteConnection(CapacitorSQLite); - } - } - - public async uninitialize() { - for (const dbKey of this.sourceDatabases.keys()) { - await this.closeDatabase(dbKey); - } - } - - private async closeDatabase(dbKey: string) { - this.loggingService.info("[MBTiles] Closing " + dbKey); - if (!this.sourceDatabases.has(dbKey)) { - this.loggingService.info(`[MBTiles] ${dbKey} was never opened`); - return; - } - try { - const db = await this.sourceDatabases.get(dbKey); - await db.close(); - this.loggingService.info("[MBTiles] Closed succefully: " + dbKey); - await this.sqlite.closeConnection(dbKey + ".db", true); - this.loggingService.info("[MBTiles] Connection closed succefully: " + dbKey); - this.sourceDatabases.delete(dbKey); - } catch (ex) { - this.loggingService.error(`[MBTiles] Unable to close ${dbKey}, ${(ex as Error).message}`); - } - } - - private async getDatabase(dbName: string): Promise { - if (this.sourceDatabases.has(dbName)) { - try { - const db = await this.sourceDatabases.get(dbName); - return db; - } catch (ex) { - this.loggingService.error(`[MBTiles] There's a problem with the connection to ${dbName}, ${(ex as Error).message}`); - } - } - this.loggingService.info(`[MBTiles] Creating connection to ${dbName}`); - this.sourceDatabases.set(dbName, this.createConnection(dbName)); - return this.sourceDatabases.get(dbName); - } - - private async createConnection(dbName: string) { - try { - const dbPromise = this.sqlite.createConnection(dbName + ".db", false, "no-encryption", 1, true); - const db = await dbPromise; - this.loggingService.info(`[MBTiles] Connection created succefully to ${dbName}`); - await db.open(); - this.loggingService.info(`[MBTiles] Connection opened succefully: ${dbName}`); - return db; - } catch (ex) { - this.loggingService.error(`[MBTiles] Failed opening ${dbName}, ${(ex as Error).message}`); - throw ex; - } - } - - private async getTileFromDatabase(dbName: string, z: number, x: number, y: number): Promise { - const db = await this.getDatabase(dbName); - - const params = [z, x, Math.pow(2, z) - y - 1]; - const queryresults = await db.query("SELECT HEX(tile_data) as tile_data_hex FROM tiles " + - "WHERE zoom_level = ? AND tile_column = ? AND tile_row = ? limit 1", - params); - if (queryresults.values.length !== 1) { - throw new Error("Unable to get tile from database"); - } - const hexData = queryresults.values[0].tile_data_hex; - let binData = new Uint8Array(hexData.match(/.{1,2}/g).map((byte: string) => parseInt(byte, 16))); - const isGzipped = binData[0] === 0x1f && binData[1] === 0x8b; - if (isGzipped) { - binData = gunzipSync(binData); - } - return binData.buffer; - } - - private getSourceNameFromUrl(url: string) { - return url.replace("custom://", "").split("/")[0]; - } - - public getTile(url: string): Promise { - const splitUrl = url.split("/"); - const dbName = this.getSourceNameFromUrl(url); - const z = +splitUrl[splitUrl.length - 3]; - const x = +splitUrl[splitUrl.length - 2]; - const y = +(splitUrl[splitUrl.length - 1].split(".")[0]); - - return this.getTileFromDatabase(dbName, z, x, y); - } -} \ No newline at end of file diff --git a/IsraelHiking.Web/src/application/services/routing.provider.ts b/IsraelHiking.Web/src/application/services/routing.provider.ts index e32ea68ee..775192932 100644 --- a/IsraelHiking.Web/src/application/services/routing.provider.ts +++ b/IsraelHiking.Web/src/application/services/routing.provider.ts @@ -11,7 +11,7 @@ import polyline from "@mapbox/polyline"; import { ResourcesService } from "./resources.service"; import { ToastService } from "./toast.service"; import { SpatialService } from "./spatial.service"; -import { DatabaseService } from "./database.service"; +import { PmTilesService } from "./pmtiles.service"; import { LoggingService } from "./logging.service"; import { RunningContextService } from "./running-context.service"; import { Urls } from "../urls"; @@ -24,7 +24,7 @@ export class RoutingProvider { constructor(private readonly httpClient: HttpClient, private readonly resources: ResourcesService, private readonly toastService: ToastService, - private readonly databaseService: DatabaseService, + private readonly pmTilesService: PmTilesService, private readonly loggingService: LoggingService, private readonly runningContextService: RunningContextService, private readonly store: Store) { @@ -231,7 +231,7 @@ export class RoutingProvider { type: "FeatureCollection", features: [] } as GeoJSON.FeatureCollection; - const arrayBuffer = await this.databaseService.getTile(`custom://IHM/${zoom}/${tileX}/${tileY}.pbf`); + const arrayBuffer = await this.pmTilesService.getTile(`custom://IHM/${zoom}/${tileX}/${tileY}.pbf`); const tile = new VectorTile(new Protobuf(arrayBuffer)); for (const layerKey of Object.keys(tile.layers)) { const layer = tile.layers[layerKey]; diff --git a/Tests/IsraelHiking.API.Tests/Controllers/FilesControllerTests.cs b/Tests/IsraelHiking.API.Tests/Controllers/FilesControllerTests.cs index cbbc0a255..eba9fea8e 100644 --- a/Tests/IsraelHiking.API.Tests/Controllers/FilesControllerTests.cs +++ b/Tests/IsraelHiking.API.Tests/Controllers/FilesControllerTests.cs @@ -171,7 +171,7 @@ public void GetOfflineFiles_NotEntitled_ShouldGetForbid() _controller.SetupIdentity(); _receiptValidationGateway.IsEntitled(Arg.Any()).Returns(false); - var results = _controller.GetOfflineFiles(DateTime.Now, false).Result as ForbidResult; + var results = _controller.GetOfflineFiles(DateTime.Now).Result as ForbidResult; Assert.IsNotNull(results); } @@ -182,7 +182,7 @@ public void GetOfflineFiles_CommunicationIssue_ShouldGetServerError() _controller.SetupIdentity(); _receiptValidationGateway.IsEntitled(Arg.Any()).Throws(new Exception("some text")); - Assert.ThrowsException(() => _controller.GetOfflineFiles(DateTime.Now, false).Result); + Assert.ThrowsException(() => _controller.GetOfflineFiles(DateTime.Now).Result); } [TestMethod] @@ -190,11 +190,11 @@ public void GetOfflineFiles_ShouldGetTheList() { _controller.SetupIdentity(); var dict = new Dictionary(); - _offlineFilesService.GetUpdatedFilesList(Arg.Any(), true) + _offlineFilesService.GetUpdatedFilesList(Arg.Any()) .Returns(dict); _receiptValidationGateway.IsEntitled(Arg.Any()).Returns(true); - var results = _controller.GetOfflineFiles(DateTime.Now, true).Result as OkObjectResult; + var results = _controller.GetOfflineFiles(DateTime.Now).Result as OkObjectResult; Assert.IsNotNull(results); var resultDict = results.Value as Dictionary; diff --git a/Tests/IsraelHiking.API.Tests/Services/OfflineFilesServiceTests.cs b/Tests/IsraelHiking.API.Tests/Services/OfflineFilesServiceTests.cs index 08d336197..c8c6eebd5 100644 --- a/Tests/IsraelHiking.API.Tests/Services/OfflineFilesServiceTests.cs +++ b/Tests/IsraelHiking.API.Tests/Services/OfflineFilesServiceTests.cs @@ -50,7 +50,7 @@ public void GetUpdatedFilesList_OneHidden_ShouldReturnEmptyList() _fileProvider.GetDirectoryContents(Arg.Any()).Returns(directory); _fileSystemHelper.IsHidden(Arg.Any()).Returns(true); - var results = _service.GetUpdatedFilesList(new DateTime(0), false); + var results = _service.GetUpdatedFilesList(new DateTime(0)); Assert.AreEqual(0, results.Count); } @@ -67,7 +67,7 @@ public void GetUpdatedFilesList_OneUpToDate_ShouldReturnEmptyList() _fileProvider.GetDirectoryContents(Arg.Any()).Returns(directory); _fileSystemHelper.IsHidden(Arg.Any()).Returns(false); - var results = _service.GetUpdatedFilesList(lastModified, false); + var results = _service.GetUpdatedFilesList(lastModified); Assert.AreEqual(0, results.Count); } @@ -85,7 +85,7 @@ public void GetUpdatedFilesList_OneNotUpToDate_ShouldReturnOneFile() _fileProvider.GetDirectoryContents(Arg.Any()).Returns(directory); _fileSystemHelper.IsHidden(Arg.Any()).Returns(false); - var results = _service.GetUpdatedFilesList(lastModified, true); + var results = _service.GetUpdatedFilesList(lastModified); Assert.AreEqual(1, results.Count); }