samedi 2 avril 2016

AutoFixture, create a list of email addresses

I'm writing some unit tests and have a class called Account which has

public Guid AccountId {get;set;}
public IEnumerable<string> EmailAddresses {get;set;}
etc...

I want to use autofixture to create the account, but I'm having trouble getting the email format.

I have tried

fixture.Register<string>(() => string.Format("{0}@acme.com", fixture.Create<string>()));

but that that leads to circular problem.

I could do this

fixture.Register<string>(() => string.Format("{0}@acme.com", fixture.Create<int>()));

But I'd rather have a string at the start of the address.

Aucun commentaire:

Enregistrer un commentaire