working example

This commit is contained in:
2018-02-26 12:07:12 +01:00
parent e5ae0c75cf
commit 0cc84f5a58
17 changed files with 4526 additions and 130 deletions

View File

@@ -1,35 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Track_1 = require("../../domain/models/Track");
var VinylCatalog = /** @class */ (function () {
function VinylCatalog() {
this.vinylList = new Array(new Track_1.Track(1, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(2, "Come Down", "Anderson Paak.", 430), new Track_1.Track(3, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(4, "DNA.", "Kendrick Lamar", 340), new Track_1.Track(5, "DNA.", "Kendrick Lamar", 340));
}
VinylCatalog.prototype.get = function () {
return this.vinylList;
};
VinylCatalog.prototype.getById = function (id) {
return this.vinylList.filter(function (track) { return track.Id == id; }).pop();
};
VinylCatalog.prototype.add = function (track) {
return this.vinylList.push(track);
};
VinylCatalog.prototype.edit = function (id, track) {
var existingTrack = this.getById(id);
existingTrack.Artist = track.Artist;
existingTrack.Title = track.Title;
existingTrack.Duration = track.Duration;
return existingTrack;
};
VinylCatalog.prototype.delete = function (id) {
var track = this.getById(id);
if (track) {
var targetIndex = this.vinylList.indexOf(track);
if (targetIndex < -1)
return null;
return this.vinylList.splice(targetIndex, 1)[0];
}
};
return VinylCatalog;
}());
exports.VinylCatalog = VinylCatalog;

View File

@@ -1,2 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -1,12 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Track = /** @class */ (function () {
function Track(id, title, artist, duration) {
this.Id = id;
this.Title = title;
this.Artist = artist;
this.Duration = duration;
}
return Track;
}());
exports.Track = Track;

View File

@@ -1,2 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@@ -1,24 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MusicCatalogService = /** @class */ (function () {
function MusicCatalogService(repository) {
this.repository = repository;
}
MusicCatalogService.prototype.get = function () {
return this.repository.get();
};
MusicCatalogService.prototype.getById = function (id) {
return this.repository.getById(id);
};
MusicCatalogService.prototype.add = function (track) {
return this.repository.add(track);
};
MusicCatalogService.prototype.edit = function (id, track) {
return this.repository.edit(id, track);
};
MusicCatalogService.prototype.delete = function (id) {
return this.repository.delete(id);
};
return MusicCatalogService;
}());
exports.MusicCatalogService = MusicCatalogService;

View File

@@ -1,20 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MusicCatalogService_1 = require("../domain/services/MusicCatalogService");
var VinylCatalog_1 = require("../adapters/music/VinylCatalog");
var MusicComponent = /** @class */ (function () {
function MusicComponent() {
var container = {
IMusicRepository: function () { return new VinylCatalog_1.VinylCatalog(); }
};
var inject = function (name) {
if (container[name]) {
return container[name];
}
throw new Error("Failed to resolve " + name);
};
var musicCatalogService = new MusicCatalogService_1.MusicCatalogService(inject("IMusicRepository"));
}
return MusicComponent;
}());
exports.MusicComponent = MusicComponent;

View File

@@ -1,9 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var MusicComponent_1 = require("./MusicComponent");
describe("MusicComponent", function () {
it('should create a new MusicComponent', function (done) {
var musicComponent = new MusicComponent_1.MusicComponent();
done();
});
});