- Unify test data for nonexistence of an object/string and collection. - Introduce more test through adding missing test data to existing tests. - Improve logic for checking absence of values to match tests. - Add missing tests for absent value validation. - Update documentation to include shared test functionality.
25 lines
897 B
TypeScript
25 lines
897 B
TypeScript
import { IApplication } from '@/domain/IApplication';
|
|
import { AsyncLazy } from '@/infrastructure/Threading/AsyncLazy';
|
|
import { IApplicationFactory } from './IApplicationFactory';
|
|
import { parseApplication } from './Parser/ApplicationParser';
|
|
|
|
export type ApplicationGetterType = () => IApplication;
|
|
const ApplicationGetter: ApplicationGetterType = parseApplication;
|
|
|
|
export class ApplicationFactory implements IApplicationFactory {
|
|
public static readonly Current: IApplicationFactory = new ApplicationFactory(ApplicationGetter);
|
|
|
|
private readonly getter: AsyncLazy<IApplication>;
|
|
|
|
protected constructor(costlyGetter: ApplicationGetterType) {
|
|
if (!costlyGetter) {
|
|
throw new Error('missing getter');
|
|
}
|
|
this.getter = new AsyncLazy<IApplication>(() => Promise.resolve(costlyGetter()));
|
|
}
|
|
|
|
public getApp(): Promise<IApplication> {
|
|
return this.getter.getValue();
|
|
}
|
|
}
|