I'm facing an interesting problem. I found out that the AutoDataAttribute can be use to minimize the "Arrange" part of your test (dependencies passed through the ctor). Awesome!
Example:
public class AutoMoqDataAttribute : AutoDataAttribute
{
public AutoMoqDataAttribute()
: base(new Fixture().Customize(new AutoMoqCustomization()))
{ }
}
[Theory, AutoMoqData]
public void Process_ValidContext_CallsK2Workflows(
[Frozen]Mock<IK2Datasource> k2,
[Frozen]Mock<IAppConfiguration> config,
PrBatchApproveBroker sut)
{
(...)
}
Now i want to use this great feature AND inject my own data into this theory:
[Theory, AutoMoqData, MemberData("Data")]
public void ExtractPayments_EmptyInvoiceNumber_IgnoresRecordsWithEmptyInvoiceNumber(
[Frozen]Mock<IExcelDatasource> xls,
SunSystemExcelDatasource sut,
List<Row> rows,
int expectedCount)
{
(...)
}
Problem: AutoData attribute will generate random data for me. The only way I found is to get rid of the AutoData attribute and use MemberData. If I do that, I need to handle object instantiations myself :)...
Is there a way to pass my classes AND some "hard-coded" data at the same time?
Thank u, Seb
Aucun commentaire:
Enregistrer un commentaire