Skip to content

Instantly share code, notes, and snippets.

View MufidJamaluddin's full-sized avatar

Mufid Jamaluddin MufidJamaluddin

  • Jakarta, Indonesia
View GitHub Profile
@MufidJamaluddin
MufidJamaluddin / mengenal_valueobject_ddd_1.cs
Created March 15, 2020 10:47
Mengenal ValueObject pada DDD
using System;
// Value Object : Money
public class Money {
public double Value {get;set;}
public string Currency {get;set;}
public string Text {
get {
return String.Format("{0} {1}", this.Currency, this.Value);
}
@MufidJamaluddin
MufidJamaluddin / jest.config.js
Created March 22, 2020 13:34
Konfigurasi Jest!
module.exports = {
"roots": [
"./src"
],
"testMatch": [
"**/__tests__/**/*.+(ts|tsx|js)",
"**/?(*.)+(spec|test).+(ts|tsx|js)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest",
@MufidJamaluddin
MufidJamaluddin / assetTransformer.js
Created March 22, 2020 13:36
Handle Jest for asset
const path = require('path');
module.exports = {
process(src, filename, config, options) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};
cd ./tests/SmartLibrary.UnitTests
dotnet test /p:CollectCoverage=true ^
/p:CoverletOutputFormat=cobertura ^
/p:CoverletOutput=./../../test_results/UnitTests/ ^
/p:Exclude="[xunit.*]*
cd ./../../
public abstract class Invoice
{
protected Motorcycle Motor {get;}
protected Duration TrackDuration {get;}
public Invoice(Motorcycle motor, Duration duration)
{
this.Motor = motor;
this.TrackDuration = duration;
}
public class MogeInvoice : Invoice
{
public MogeInvoice(Motorcycle motor, Duration duration) : base(Motorcycle motor, Duration duration)
{
}
public override Double CalculateInvoice()
{
// perhitungan invoice Moge
}
public class Invoice
{
public Double CalculateInvoice(Motorcycle motor, Duration duration)
{
// perhitungan tagihan tracking motor pribadi
}
public void PayInvoice(double invoice)
{
// pembayaran struk tagihan
}
public class Invoice
{
public Double CalculateInvoice(Motorcycle motor, Duration duration)
{
if(motor.type = "rent")
{
// perhitungan tagihan tracking motor sewaan
}
else if(motor.type = "loan")
{
public class Motorcycle
{
public string ProductName {get;set;}
public double Price {get;set;}
public void Buy(PublicUser user)
{
// beli
}
}
public class UnreleasedMotorcycle
{
public string ProductName {get;set;}
public Date ReleasedDate {get;set;}
}
public class AbgooMotor : UnreleasedMotorcycle
{
//...
}