Skip to content

Commit

Permalink
add another INotifyPropertyChanged test
Browse files Browse the repository at this point in the history
  • Loading branch information
lofcz committed Jan 8, 2025
1 parent 40b6e9f commit 51261f2
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 39 additions & 0 deletions FastCloner.Tests/SpecialCaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,45 @@ public void NotifyPropertyChanged_With_Collection_Clone()
});
}

public class INotifyTest : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

private string _prop;
public string Prop
{
get => _prop;

set
{
_prop = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Prop)));
}
}
}

[Test]
public void Test_Notify_Triggered_Correctly()
{
// Arrange
List<string> output = [];
INotifyTest a = new INotifyTest();
a.PropertyChanged += (sender, args) =>
{
output.Add(((INotifyTest)sender).Prop);
};

// Act
a.Prop = "A changed";
INotifyTest b = a.DeepClone();
b.Prop = "B changed";
b.Prop = "B changed again";

// Assert
Assert.That(output, Has.Count.EqualTo(1));
Assert.That(output[0], Is.EqualTo("A changed"));
}

public class NotifyingPerson : INotifyPropertyChanged
{
private string _name;
Expand Down
2 changes: 1 addition & 1 deletion FastCloner/FastCloner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</PropertyGroup>

<PropertyGroup>
<Version>3.1.4</Version>
<Version>3.1.5</Version>

<Title>FastCloner</Title>
<Description>Fast deep cloning library for .NET 8+. Supports both deep and shallow cloning. Extensively tested, focused on performance and stability even on complicated object graphs.</Description>
Expand Down

0 comments on commit 51261f2

Please sign in to comment.