Skip to content

9swampy/InpcTracer

Repository files navigation

InpcTracer

========== Inspired by Seikilos
Published on NuGet

I needed to clean up testing of INotifyPropertyChanged implementations in an application I'm working on. Seikilos' Gist inspired me, kudos. I use FakeItEasy and have altered the usage quite a bit by adopting their MustHave(Repeated) fluent syntax to be more consistent.

I'm only dabbling with Git having been an SVN user for many years. Hopefully I'm not stepping on any toes or doing anything incorrect!

Arrange
```csharp ITraceable target = A.Fake(); A.CallTo(target).Where(x => x.Method.Name == "set_Active") .Invokes(() => { target.PropertyChanged += Raise.With(new PropertyChangedEventArgs("Active")).Now; });

var tracer = new InpcTracer.InpcTracer(target);


  <h5>
    <b>Check for one event</b>
  </h5>
```csharp
Assert.IsTrue(tracer.WhileProcessing(() => target.Active = true)
                    .RecordedEvent(() => target.Active)
                    .ExactlyOnce());
// or
tracer.WhileProcessing(() => target.Active = true)
      .RecordedEvent(() => target.Active)
      .MustHaveHappened(Repeated.Exactly.Once);
Check for exact order of two events
```csharp // Check for exact order of two events tracer.WhileProcessing(() => { target.Active = false; target.Active = true; }) .FirstRecordedEvent(() => target.Active) .ThenRecordedEvent(() => target.Active); ```

About

A fluent interface for unit testing INotifyPropertyChanged events

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages