Skip to content

Commit 7a9c76d

Browse files
committed
Add MoneyCollectionExtensions tests
1 parent 699f624 commit 7a9c76d

File tree

4 files changed

+192
-0
lines changed

4 files changed

+192
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
namespace Singulink.Globalization.Tests.MoneyCollectionExtensionsTests;
2+
3+
public class ToImmutableMoneySet
4+
{
5+
private static readonly CurrencyRegistry NewRegistry = new("New Registry", [Currency.Get("USD"), Currency.Get("CAD"), Currency.Get("EUR")]);
6+
private static readonly ImmutableArray<Money> SetValues = [new(100m, "USD"), new(50m, "CAD"), new(25m, "EUR")];
7+
8+
[PrefixTestClass]
9+
public class Set : Tests<MoneySet> { }
10+
11+
[PrefixTestClass]
12+
public class SortedSet : Tests<SortedMoneySet> { }
13+
14+
[PrefixTestClass]
15+
public class ImmutableSet : Tests<ImmutableMoneySet> { }
16+
17+
[PrefixTestClass]
18+
public class ImmutableSortedSet : Tests<ImmutableSortedMoneySet> { }
19+
20+
[TestMethod]
21+
public void OtherCollection_SetsRegistry()
22+
{
23+
var set = SetValues.ToImmutableMoneySet(NewRegistry);
24+
set.Registry.ShouldBeSameAs(NewRegistry);
25+
set.ShouldBe(SetValues, ignoreOrder: true);
26+
}
27+
28+
public class Tests<T> where T : IReadOnlyMoneySet
29+
{
30+
private static readonly IReadOnlyMoneySet Set = T.Create(NewRegistry, SetValues);
31+
32+
[TestMethod]
33+
public void DefaultMoneySet_SetsRegistry()
34+
{
35+
var set = Set.ToImmutableMoneySet();
36+
set.Registry.ShouldBeSameAs(NewRegistry);
37+
set.ShouldBe(SetValues, ignoreOrder: true);
38+
}
39+
40+
[TestMethod]
41+
public void MoneySet_SetsRegistry()
42+
{
43+
var set = Set.ToImmutableMoneySet(CurrencyRegistry.Default);
44+
set.Registry.ShouldBeSameAs(CurrencyRegistry.Default);
45+
set.ShouldBe(SetValues, ignoreOrder: true);
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
namespace Singulink.Globalization.Tests.MoneyCollectionExtensionsTests;
2+
3+
public class ToImmutableSortedMoneySet
4+
{
5+
private static readonly CurrencyRegistry newRegistry = new("New Registry", [Currency.Get("USD"), Currency.Get("CAD"), Currency.Get("EUR")]);
6+
private static readonly ImmutableArray<Money> SetValues = [new(100m, "USD"), new(50m, "CAD"), new(25m, "EUR")];
7+
8+
[PrefixTestClass]
9+
public class Set : Tests<MoneySet>;
10+
11+
[PrefixTestClass]
12+
public class SortedSet : Tests<SortedMoneySet> { }
13+
14+
[PrefixTestClass]
15+
public class ImmutableSet : Tests<ImmutableMoneySet> { }
16+
17+
[PrefixTestClass]
18+
public class ImmutableSortedSet : Tests<ImmutableSortedMoneySet> { }
19+
20+
[TestMethod]
21+
public void OtherCollection_SetsRegistryAndCopiesValues()
22+
{
23+
var set = SetValues.ToImmutableSortedMoneySet(newRegistry);
24+
set.Registry.ShouldBeSameAs(newRegistry);
25+
set.ShouldBe(SetValues, ignoreOrder: true);
26+
}
27+
28+
public class Tests<T> where T : IReadOnlyMoneySet
29+
{
30+
private static readonly IReadOnlyMoneySet Set = T.Create(newRegistry, SetValues);
31+
32+
[TestMethod]
33+
public void DefaultMoneySet_SetsRegistryAndCopiesValues()
34+
{
35+
var set = Set.ToImmutableSortedMoneySet();
36+
set.Registry.ShouldBeSameAs(newRegistry);
37+
set.ShouldBe(SetValues, ignoreOrder: true);
38+
}
39+
40+
[TestMethod]
41+
public void MoneySet_SetsRegistryAndCopiesValues()
42+
{
43+
var set = Set.ToImmutableSortedMoneySet(CurrencyRegistry.Default);
44+
set.Registry.ShouldBeSameAs(CurrencyRegistry.Default);
45+
set.ShouldBe(SetValues, ignoreOrder: true);
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
namespace Singulink.Globalization.Tests.MoneyCollectionExtensionsTests;
2+
3+
public class ToMoneySet
4+
{
5+
private static readonly CurrencyRegistry NewRegistry = new("New Registry", [Currency.Get("USD"), Currency.Get("CAD"), Currency.Get("EUR")]);
6+
private static readonly ImmutableArray<Money> SetValues = [new(100m, "USD"), new(50m, "CAD"), new(25m, "EUR")];
7+
8+
[PrefixTestClass]
9+
public class Set : Tests<MoneySet> { }
10+
11+
[PrefixTestClass]
12+
public class SortedSet : Tests<SortedMoneySet> { }
13+
14+
[PrefixTestClass]
15+
public class ImmutableSet : Tests<ImmutableMoneySet> { }
16+
17+
[PrefixTestClass]
18+
public class ImmutableSortedSet : Tests<ImmutableSortedMoneySet> { }
19+
20+
[TestMethod]
21+
public void OtherCollection_SetsRegistry()
22+
{
23+
var set = SetValues.ToMoneySet(NewRegistry);
24+
set.Registry.ShouldBeSameAs(NewRegistry);
25+
set.ShouldBe(SetValues, ignoreOrder: true);
26+
}
27+
28+
public class Tests<T> where T : IReadOnlyMoneySet
29+
{
30+
private static readonly IReadOnlyMoneySet Set = T.Create(NewRegistry, SetValues);
31+
32+
[TestMethod]
33+
public void DefaultMoneySet_SetsRegistry()
34+
{
35+
var set = Set.ToMoneySet();
36+
set.Registry.ShouldBeSameAs(NewRegistry);
37+
set.ShouldBe(SetValues, ignoreOrder: true);
38+
}
39+
40+
[TestMethod]
41+
public void MoneySet_SetsRegistry()
42+
{
43+
var set = Set.ToMoneySet(CurrencyRegistry.Default);
44+
set.Registry.ShouldBeSameAs(CurrencyRegistry.Default);
45+
set.ShouldBe(SetValues, ignoreOrder: true);
46+
}
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
namespace Singulink.Globalization.Tests.MoneyCollectionExtensionsTests;
2+
3+
public class ToSortedMoneySet
4+
{
5+
private static readonly CurrencyRegistry newRegistry = new("New Registry", [Currency.Get("USD"), Currency.Get("CAD"), Currency.Get("EUR")]);
6+
private static readonly ImmutableArray<Money> SetValues = [new(100m, "USD"), new(50m, "CAD"), new(25m, "EUR")];
7+
8+
[PrefixTestClass]
9+
public class Set : Tests<MoneySet>;
10+
11+
[PrefixTestClass]
12+
public class SortedSet : Tests<SortedMoneySet> { }
13+
14+
[PrefixTestClass]
15+
public class ImmutableSet : Tests<ImmutableMoneySet> { }
16+
17+
[PrefixTestClass]
18+
public class ImmutableSortedSet : Tests<ImmutableSortedMoneySet> { }
19+
20+
[TestMethod]
21+
public void OtherCollection_SetsRegistryAndCopiesValues()
22+
{
23+
var set = SetValues.ToSortedMoneySet(newRegistry);
24+
set.Registry.ShouldBeSameAs(newRegistry);
25+
set.ShouldBe(SetValues, ignoreOrder: true);
26+
}
27+
28+
public class Tests<T> where T : IReadOnlyMoneySet
29+
{
30+
private static readonly IReadOnlyMoneySet Set = T.Create(newRegistry, SetValues);
31+
32+
[TestMethod]
33+
public void DefaultMoneySet_SetsRegistryAndCopiesValues()
34+
{
35+
var set = Set.ToSortedMoneySet();
36+
set.Registry.ShouldBeSameAs(newRegistry);
37+
set.ShouldBe(SetValues, ignoreOrder: true);
38+
}
39+
40+
[TestMethod]
41+
public void MoneySet_SetsRegistryAndCopiesValues()
42+
{
43+
var set = Set.ToSortedMoneySet(CurrencyRegistry.Default);
44+
set.Registry.ShouldBeSameAs(CurrencyRegistry.Default);
45+
set.ShouldBe(SetValues, ignoreOrder: true);
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)