Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement ISet and update namespace.
- Loading branch information
Showing
11 changed files
with
336 additions
and
246 deletions.
There are no files selected for viewing
File renamed without changes.
111 changes: 111 additions & 0 deletions
111
specs/Qowaiv.Specs/Collections/Email_address_set_specs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using Qowaiv.Collections; | ||
|
||
namespace Collections.Email_address_set_specs; | ||
|
||
public class Appends | ||
{ | ||
[Test] | ||
public void new_email_address_in_ascending_order([Range(0, 25)] int index) | ||
{ | ||
var emails = Enumerable.Range(0, 26).Select(i => EmailAddress.Parse($"{(char)('A' + i)}@qowaiv.org")).ToArray(); | ||
var collection = EmailAddressCollection.New(emails); | ||
|
||
IReadOnlyCollection<EmailAddress> appended = collection.Append(EmailAddress.Parse($"{emails[index]}.com")); | ||
|
||
appended.Should().HaveCount(collection.Count + 1); | ||
appended.Should().BeInAscendingOrder(); | ||
} | ||
|
||
[Test] | ||
public void existing_email_address_changes_nothing([Range(0, 25)] int index) | ||
{ | ||
var emails = Enumerable.Range(0, 26).Select(i => EmailAddress.Parse($"{(char)('A' + i)}@qowaiv.org")).ToArray(); | ||
var collection = EmailAddressCollection.New(emails); | ||
|
||
object appended = collection.Append(emails[index]); | ||
appended.Should().Be(collection); | ||
} | ||
|
||
[TestCase("")] | ||
[TestCase("?")] | ||
public void changes_nothing_for_empty_or_unknown(EmailAddress notKnown) | ||
{ | ||
object appended = Svo.EmailAddressCollection.Append(notKnown); | ||
appended.Should().Be(Svo.EmailAddressCollection); | ||
} | ||
} | ||
|
||
public class Implements_ISet | ||
{ | ||
private readonly EmailAddressCollection empty = EmailAddressCollection.Empty; | ||
private readonly EmailAddressCollection set = Svo.EmailAddressCollection; | ||
private readonly EmailAddressCollection more = Svo.EmailAddressCollection.Append(EmailAddress.Parse("jimmy@hendrix.com")); | ||
private readonly EmailAddressCollection less = EmailAddressCollection.New(Svo.EmailAddressCollection.Skip(1)); | ||
private readonly EmailAddressCollection other = EmailAddressCollection.New(Svo.EmailAddressCollection.Skip(1).Concat([EmailAddress.Parse("jimmy@hendrix.com")])); | ||
private readonly EmailAddressCollection different = EmailAddressCollection.New([EmailAddress.Parse("jimmy@hendrix.com"), EmailAddress.Parse("nick@drake.co.uk")]); | ||
|
||
[Test] | ||
public void Is_subset() | ||
{ | ||
empty.IsSubsetOf(empty).Should().Be(empty.ToHashSet().IsSubsetOf(empty)); | ||
empty.IsSubsetOf(set).Should().Be(empty.ToHashSet().IsSubsetOf(set)); | ||
|
||
set.IsSubsetOf(set).Should().Be(set.ToHashSet().IsSubsetOf(set)); | ||
set.IsSubsetOf(more).Should().Be(set.ToHashSet().IsSubsetOf(more)); | ||
set.IsSubsetOf(less).Should().Be(set.ToHashSet().IsSubsetOf(less)); | ||
set.IsSubsetOf(other).Should().Be(set.ToHashSet().IsSubsetOf(other)); | ||
set.IsSubsetOf(different).Should().Be(set.ToHashSet().IsSubsetOf(different)); | ||
} | ||
|
||
[Test] | ||
public void Is_proper_subset() | ||
{ | ||
empty.IsProperSubsetOf(empty).Should().Be(empty.ToHashSet().IsProperSubsetOf(empty)); | ||
empty.IsProperSubsetOf(set).Should().Be(empty.ToHashSet().IsProperSubsetOf(set)); | ||
|
||
set.IsProperSubsetOf(set).Should().Be(set.ToHashSet().IsProperSubsetOf(set)); | ||
set.IsProperSubsetOf(more).Should().Be(set.ToHashSet().IsProperSubsetOf(more)); | ||
set.IsProperSubsetOf(less).Should().Be(set.ToHashSet().IsProperSubsetOf(less)); | ||
set.IsProperSubsetOf(other).Should().Be(set.ToHashSet().IsProperSubsetOf(other)); | ||
set.IsProperSubsetOf(different).Should().Be(set.ToHashSet().IsProperSubsetOf(different)); | ||
} | ||
|
||
[Test] | ||
public void Is_superset() | ||
{ | ||
empty.IsSupersetOf(empty).Should().Be(empty.ToHashSet().IsSupersetOf(empty)); | ||
empty.IsSupersetOf(set).Should().Be(empty.ToHashSet().IsSupersetOf(set)); | ||
|
||
set.IsSupersetOf(set).Should().Be(set.ToHashSet().IsSupersetOf(set)); | ||
set.IsSupersetOf(more).Should().Be(set.ToHashSet().IsSupersetOf(more)); | ||
set.IsSupersetOf(less).Should().Be(set.ToHashSet().IsSupersetOf(less)); | ||
set.IsSupersetOf(other).Should().Be(set.ToHashSet().IsSupersetOf(other)); | ||
set.IsSupersetOf(different).Should().Be(set.ToHashSet().IsSupersetOf(different)); | ||
} | ||
|
||
[Test] | ||
public void Is_proper_superset() | ||
{ | ||
empty.IsProperSupersetOf(empty).Should().Be(empty.ToHashSet().IsProperSupersetOf(empty)); | ||
empty.IsProperSupersetOf(set).Should().Be(empty.ToHashSet().IsProperSupersetOf(set)); | ||
|
||
set.IsProperSupersetOf(set).Should().Be(set.ToHashSet().IsProperSupersetOf(set)); | ||
set.IsProperSupersetOf(more).Should().Be(set.ToHashSet().IsProperSupersetOf(more)); | ||
set.IsProperSupersetOf(less).Should().Be(set.ToHashSet().IsProperSupersetOf(less)); | ||
set.IsProperSupersetOf(other).Should().Be(set.ToHashSet().IsProperSupersetOf(other)); | ||
set.IsProperSupersetOf(different).Should().Be(set.ToHashSet().IsProperSupersetOf(different)); | ||
} | ||
|
||
[Test] | ||
public void Overlaps() | ||
{ | ||
empty.Overlaps(empty).Should().Be(empty.ToHashSet().Overlaps(empty)); | ||
empty.Overlaps(set).Should().Be(empty.ToHashSet().Overlaps(set)); | ||
|
||
set.Overlaps(set).Should().Be(set.ToHashSet().Overlaps(set)); | ||
set.Overlaps(more).Should().Be(set.ToHashSet().Overlaps(more)); | ||
set.Overlaps(less).Should().Be(set.ToHashSet().Overlaps(less)); | ||
set.Overlaps(other).Should().Be(set.ToHashSet().Overlaps(other)); | ||
set.Overlaps(different).Should().Be(set.ToHashSet().Overlaps(different)); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using Qowaiv.Chemistry; | ||
using Qowaiv.Collections; | ||
using Qowaiv.Customization; | ||
using Qowaiv.Sustainability; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.