lundi 27 juin 2016

Sequence contains no elements being thrown only from AutoFixture

I use Ploeh.Autofixture with my BDD tests.

I'm trying to write a fixture for a User class which in turn uses CentralConfiguration Class. CentralConfiguration constructor looks like this.

public CentralConfiguration(IConfigurationRepository configurationRepository, ILogger logger)
{
   _logger = logger;
   _configuration = configurationRepository.Single();
   LogPropertyValues();
}

The second line in the constructor, although working fine when used by a user, throws "Sequence contains no elements" exception EVERY TIME I try to build a fixture for tests. I even tried building a Configuration object manually and using

configuration.Single().Returns(myCustomObject)

but nothing changed (actually this line started throwing the same exception).

What am I doing wrong, and how can I circumvent this issue?

Aucun commentaire:

Enregistrer un commentaire