Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created Oct 20, 2021
Embed
What would you like to do?
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