Skip to main content

All Questions

0 votes
3 answers
2k views

Unit Testing: Constructor Injection with Fake Objects - Bad Tests?

In The Art of Unit Testing, 2nd Ed., the author gives the following example for injecting a stub using constructor injection and a "fake object". The goal of the "fake object" is to inherit the ...
8protons's user avatar
  • 1,379
0 votes
1 answer
367 views

Unit testing for a method in a class which uses constructor DI (prism)

I have a class that uses constructor DI for IEventAggregator public SomeViewModel(IEventAggregator eventAggregator) { this.eventAggregator = eventAggregator; ...
Bells's user avatar
  • 443
42 votes
7 answers
20k views

Is using "new" in the constructor always bad?

I have read that using "new" in a constructor (for any other objects than simple value ones) is bad practice as it makes unit testing impossible (as then those collaborators needs to be created too ...
Ezoela Vacca's user avatar
12 votes
2 answers
8k views

Unit Test to test the creation of a Domain Object

I have a Unit Test, which looks like this: [Test] public void Should_create_person() { Assert.DoesNotThrow(() => new Person(Guid.NewGuid(), new DateTime(1972, 01, 01)); } I am asserting that ...
w0051977's user avatar
  • 7,139