dukesta3
dukesta3

Reputation: 137

How to test BusyIndicator IsBusy property using TDD

I am reading Professional Test Driven Development with C# and it has opened up my eyes to some cool approaches and frameworks. I really like the flow of red-green-refactor and I knocked out a ton of library code in the past couple of weeks.

For the WPF front end, I wanted to try the same sort of approach with the ViewModel. Everything was going fine until I started thinking about how to add the bool that the View's BusyIndicator IsBusy property will bind to. More specifically, what tests should I write so that I can make sure long methods will set IsBusy properly. I know I could probably do this easily without doing the pure TDD approach, but was curious how others approach simple tasks like this.

Upvotes: 3

Views: 140

Answers (1)

Alexander
Alexander

Reputation: 2318

If I understand your question correctly, you should be able to create a mock instance of your View. Then in your test(s), once you have the test conditions arranged & have acted upon them (the first & second A's in "Arrange/Act/Assert"; see: http://www.telerik.com/help/justmock/basic-usage-arrange-act-assert.html), you can verify whether the IsBusy property evaluates to true.

Also, you may find it useful to also have some type of conditional check added to the property, so as to behave slightly differently while testing. Here's a nice example of how to accomplish this:

Upvotes: 1

Related Questions