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!
Packages I'm using:
<package id="AutoFixture" version="3.47.8" targetFramework="net452" />
<package id="AutoFixture.AutoMoq" version="3.47.8" targetFramework="net452" />
<package id="AutoFixture.Xunit" version="3.47.8" targetFramework="net461" />
<package id="Castle.Core" version="3.3.3" targetFramework="net461" />
<package id="Moq" version="4.5.10" targetFramework="net461" />
<package id="xunit" version="2.1.0" targetFramework="net461" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net461" />
<package id="xunit.core" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net461" />
<package id="xunit.extensions" version="1.9.0.1566" targetFramework="net461" />
When using xUnit.net 2, you should use AutoFixture.Xunit2, not AutoFixture.Xunit.
You'll notice in your package list that you have xunit.extensions
version 1.9.0.1566, which isn't compatible with xUnit.net 2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With