Reputation: 1394
I have a class Alias
. I have used it with Autofixture and everything have been working OK. The tests started to fail however when I've added an interface property to my class.
So that's my class:
public class Alias : NotifyPropertyChanged
{
private Alias()
{
Nicks = new List<string>();
History = new History(this);
}
public IDownloader Downloader {get;set;}
}
I am using it in test like that:
Fixture fixture = new Fixture();
var alias = fixture.Create<Alias>();
And got Exception:
loeh.AutoFixture.ObjectCreationException : AutoFixture was unable to create an instance from Core.Helpers.IDownloader...
I've tried to register the interface by fixture.Register<IVKDownloader>(() => new Downloader());
but I still get this error.
If I change this property to use type instead of the interface public Downloader Downloader {get;set;}
everything is working normally. How could I fix this?
Upvotes: 0
Views: 1274
Reputation: 6553
fixture.Register<IVKDownloader>(() => new Downloader());
Looks like that is a typo for IDownloader
fixture.Register<IDownloader>(() => new Downloader());
Upvotes: 6