mardi 28 juin 2016

XUnit and AutoFixture Exception No Data found for (test name)

I have a very simple test as shown below. I try to freeze my two dependencies using the AutoDataAttribute + AutoMoqCustomization.

class AutoMoqDataAttribute : AutoDataAttribute
{
    public AutoMoqDataAttribute()
        : base(new Fixture().Customize(new AutoMoqCustomization()))
    { }
}

public class PrBatchEndorseBrokerTest
{
    [Theory, AutoMoqData]
    public void Process_ValidContext_CallsK2Workflows(
        [Frozen]Mock<IK2Datasource> k2,
        [Frozen]Mock<IAppConfiguration> config,
        PrBatchEndorseBroker sut)
    {
        // Arrange
        var data = new Dictionary<string, object>
        {
            ["Workflow"] = @"KLPurchaseRequest\PR",
            ["Activity"] = "Endorser",
            ["ViewFormURL"] = "/Form/KLPurchaseRequestApproval.Form",
            ["PositiveOutcome"] = "Endorse",
            ["NegativeOutcome"] = "Reject"
        };

        // Act
        sut.Process();

        // Assert
        k2.Verify(x =>
            x.StartInstance(It.IsAny<string>(),
                            It.Is<Dictionary<string, object>>(d =>
                                data.Keys.All(k => d[k] == data[k])))
            , Times.Once());
    }
}

For some reasons, when i run this test, i'm getting the following error: System.InvalidOperationException: No data found for BlackBox.Stakhanov.Broker.Test.PrBatchEndorseBrokerTest.Process_ValidContext_CallsK2Workflows

I tried many things and i can't make it work! I think i'm missing something big and probably obvious!

I'm using the latest versions of XUnit + AutoFixture.AutoMoq + AutoFixture.XUnit.

Thank you for your help, Regards, Seb

Aucun commentaire:

Enregistrer un commentaire