Simple Tests for Gamesystem Adding and Removing
This commit is contained in:
parent
e43567f2ca
commit
796f1e3a05
23
e2e/game-model/AddingGamesystems.spec.ts
Normal file
23
e2e/game-model/AddingGamesystems.spec.ts
Normal file
@ -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);
|
||||
})
|
||||
});
|
25
e2e/game-model/RemovingGamesystems.spec.ts
Normal file
25
e2e/game-model/RemovingGamesystems.spec.ts
Normal file
@ -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);
|
||||
})
|
||||
});
|
29
src/app/game-model/GameModel.ts
Normal file
29
src/app/game-model/GameModel.ts
Normal file
@ -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);
|
||||
}
|
||||
}
|
12
src/app/game-model/game-model.module.ts
Normal file
12
src/app/game-model/game-model.module.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
imports: [
|
||||
CommonModule
|
||||
]
|
||||
})
|
||||
export class GameModelModule { }
|
8
src/app/game-model/gamesystems/Gamesystem.ts
Normal file
8
src/app/game-model/gamesystems/Gamesystem.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export class Gamesystem {
|
||||
gamesystemName: string
|
||||
constructor(gamesystemName: string) {
|
||||
this.gamesystemName = gamesystemName;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user