diff --git a/e2e/game-model/AddingGamesystems.spec.ts b/e2e/game-model/AddingGamesystems.spec.ts new file mode 100644 index 0000000..4d65fd0 --- /dev/null +++ b/e2e/game-model/AddingGamesystems.spec.ts @@ -0,0 +1,23 @@ +import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; +import { test, expect } from '@playwright/test'; +import * as PATH from 'path'; +import {GameModel} from "../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; + +test.describe('Adding Gamesystems', () => { + + test("Test simple adding of Gamesystems", async () => { + const gameModel = new GameModel("GameModel"); + const gamesystem = new Gamesystem("Gamesystem"); + gameModel.addGamesystem(gamesystem); + expect(gameModel.gamesystems.includes(gamesystem)).toBeTruthy(); + }) + + test("Test duplicates when adding Gamesystems", async () => { + const gameModel = new GameModel("GameModel"); + const gamesystem = new Gamesystem("Gamesystem"); + gameModel.addGamesystem(gamesystem); + gameModel.addGamesystem(gamesystem) + expect(gameModel.gamesystems.length).toEqual(1); + }) +}); diff --git a/e2e/game-model/RemovingGamesystems.spec.ts b/e2e/game-model/RemovingGamesystems.spec.ts new file mode 100644 index 0000000..e5777fe --- /dev/null +++ b/e2e/game-model/RemovingGamesystems.spec.ts @@ -0,0 +1,25 @@ +import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright'; +import { test, expect } from '@playwright/test'; +import * as PATH from 'path'; +import {GameModel} from "../../src/app/game-model/GameModel"; +import {Gamesystem} from "../../src/app/game-model/gamesystems/Gamesystem"; + +test.describe('Removing Gamesystems', () => { + + test("Test simple removing of Gamesystems", async () => { + const gameModel = new GameModel("GameModel"); + const gamesystem = new Gamesystem("Gamesystem"); + gameModel.addGamesystem(gamesystem); + + gameModel.removeGamesystem(gamesystem); + expect(gameModel.gamesystems.length).toEqual(0); + }) + + test("Test removing of empty gamesystems", async () => { + const gameModel = new GameModel("GameModel"); + const gamesystem = new Gamesystem("Gamesystem"); + + gameModel.removeGamesystem(gamesystem); + expect(gameModel.gamesystems.length).toEqual(0); + }) +}); diff --git a/src/app/game-model/GameModel.ts b/src/app/game-model/GameModel.ts new file mode 100644 index 0000000..8bc7dbf --- /dev/null +++ b/src/app/game-model/GameModel.ts @@ -0,0 +1,29 @@ +import {Gamesystem} from "./gamesystems/Gamesystem"; + +export class GameModel { + private readonly _gameModelName: string + + private _gamesystems: Gamesystem[] = []; + + constructor(gameModelName: string) { + this._gameModelName = gameModelName; + } + get gameModelName(): string { + return this._gameModelName; + } + + + get gamesystems(): Gamesystem[] { + return this._gamesystems; + } + + addGamesystem(gamesystem: Gamesystem) { + if(!this.gamesystems.includes(gamesystem)) { + this._gamesystems.push(gamesystem); + } + } + + removeGamesystem(gamesystem : Gamesystem) { + this._gamesystems = this._gamesystems.filter(g => g !== gamesystem); + } +} diff --git a/src/app/game-model/game-model.module.ts b/src/app/game-model/game-model.module.ts new file mode 100644 index 0000000..8d35a43 --- /dev/null +++ b/src/app/game-model/game-model.module.ts @@ -0,0 +1,12 @@ +import { NgModule } from '@angular/core'; +import { CommonModule } from '@angular/common'; + + + +@NgModule({ + declarations: [], + imports: [ + CommonModule + ] +}) +export class GameModelModule { } diff --git a/src/app/game-model/gamesystems/Gamesystem.ts b/src/app/game-model/gamesystems/Gamesystem.ts new file mode 100644 index 0000000..989e9c0 --- /dev/null +++ b/src/app/game-model/gamesystems/Gamesystem.ts @@ -0,0 +1,8 @@ +export class Gamesystem { + gamesystemName: string + constructor(gamesystemName: string) { + this.gamesystemName = gamesystemName; + } + + +}