All Questions
Tagged with constructors unit-testing
4 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 ...
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;
...
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 ...
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 ...