Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sschmid committed Nov 15, 2022
1 parent b99c22e commit 91f5bd1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/DesperateDevs.Extensions.Tests/DictionaryExtensionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,31 @@ namespace DesperateDevs.Extensions.Tests
public class DictionaryExtensionTests
{
[Fact]
public void MergesIntoDictionary()
public void MergesDictionary()
{
var d1 = new Dictionary<string, string>
{
{"k1", "v1"},
{"k2", "v2"}
};

var d2 = new Dictionary<string, string>
{
{"k1", "v2"},
{"k3", "v3"}
};

var merged = d1.Merge(d2);
merged.Should().BeSameAs(d1);
merged.Should().HaveCount(3);
merged.Keys.Should().Contain("k1");
merged.Keys.Should().Contain("k2");
merged.Keys.Should().Contain("k3");
merged["k1"].Should().Be("v2");
}

[Fact]
public void MergesDictionaries()
{
var d1 = new Dictionary<string, string>
{
Expand Down
15 changes: 15 additions & 0 deletions tests/DesperateDevs.Reflection.Tests/PublicMemberInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ public void ClonesObjectAndSetsPublicMembers()
clone.PublicProperty.Should().Be(obj.PublicProperty);
}

[Fact]
public void ClonesGenericObjectAndSetsPublicMembers()
{
var obj = new TestClassWithFieldsAndProperties
{
PublicField = "field",
PublicProperty = "property"
};

var clone = obj.PublicMemberClone<TestClassWithFieldsAndProperties>();
clone.Should().NotBeSameAs(obj);
clone.PublicField.Should().Be(obj.PublicField);
clone.PublicProperty.Should().Be(obj.PublicProperty);
}

[Fact]
public void CopiesPublicMembersToOtherObject()
{
Expand Down

0 comments on commit 91f5bd1

Please sign in to comment.