I Need to test the following code?
public double LoadPercent
{
get { return _loadPercent; }
private set
{
RaisePropertyChanging("LoadPercent");
_loadPercent = value;
RaisePropertyChanged("LoadPercent");
}
}
Im using xUnit framework and if the set
was not private
i would write the test like this:
[Fact]
public void LoadPercentTest()
{
// Arrange
var loader = new Loader();
bool notify = false;
// Act
loader.PropertyChanged += (sender, args) =>
{
if (args.PropertyName == "LoadPercent")
{
notify = true;
}
};
loader.LoadPercent = 20;
// Assert
Assert.True(notify, "Notification Failed");
}
I'm new to unit testing (beginner level), any help will be appreciated.