Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created October 20, 2021 20:59
Show Gist options
  • Save dcomartin/167c01dc4945364b101373bc9955a253 to your computer and use it in GitHub Desktop.
Save dcomartin/167c01dc4945364b101373bc9955a253 to your computer and use it in GitHub Desktop.
using Xunit;
namespace ValueObject
{
public record Currency(string Symbol)
{
public static Currency CAD => new("CAD");
public static Currency USD => new("USD");
}
public record Money
{
public Currency Currency { get; }
public decimal Amount { get; }
public Money(Currency currency, decimal amount)
{
Currency = currency;
Amount = amount;
}
}
public class MoneyTests
{
[Fact]
public void Test()
{
var money1 = new Money(Currency.CAD, 100);
var money2 = new Money(Currency.CAD, 100);
Assert.Equal(money1, money2);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment