The following is a test project I'm trying to build to reproduce the issue you've described.
Quote:using Microsoft.Xrm.Sdk;
using Ploeh.AutoFixture;
using Ploeh.AutoFixture.AutoNSubstitute;
using Ploeh.AutoFixture.Xunit;
using Xunit;
namespace ClassLibrary3
{
public class NSubstituteCrmAutoData : AutoDataAttribute
{
/// <summary>
/// Initializes a new instance of the <see cref="Test" /> class.
/// </summary>
public NSubstituteCrmAutoData()
: base(
new Fixture().Customize(
new TestConventions(new CrmTestConventions(), new AutoNSubstituteCustomization())))
{
}
}
public class TestConventions : CompositeCustomization
{
/// <summary>
/// Initializes a new instance of the <see cref="TestConventions" /> class.
/// </summary>
/// <param name="crmTestConventions">
/// <see cref="CrmTestConventions" /> or a
/// derived implementation setting up conventions for the fixture.
/// </param>
/// <param name="autoMockCustomization">One of the AutoFixture automocking customizations.</param>
public TestConventions(
CrmTestConventions crmTestConventions,
ICustomization autoMockCustomization)
: base(
new OmitAutoPropertiesCustomization(),
crmTestConventions,
autoMockCustomization)
{
}
private class OmitAutoPropertiesCustomization : ICustomization
{
public void Customize(IFixture fixture)
{
fixture.OmitAutoProperties = true;
}
}
}
public class CrmTestConventions : ICustomization
{
/// <summary>
/// Customizes the specified fixture to return working <see cref="Entity" /> and <see cref="EntityReference" />objects.
/// </summary>
/// <param name="fixture">The fixture to customize.</param>
public virtual void Customize(IFixture fixture)
{
fixture.Customize<Entity>(f => f.WithAutoProperties().Without(e => e.ExtensionData));
fixture.Customize<EntityReference>(f => f.WithAutoProperties().Without(e => e.ExtensionData));
CustomizeSpecific(fixture);
}
/// <summary>
/// Override to register more specific default implementations for testing individual projects.
/// </summary>
/// <param name="fixture">The fixture to customize.</param>
protected virtual void CustomizeSpecific(IFixture fixture)
{
}
}
public interface IInterface
{
}
public class InterfaceImplemented : IInterface
{
}
public class FixtureX
{
[Theory, NSubstituteCrmAutoData]
public void Run_ExecutesUpdateEntityOnce([Frozen] IInterface intr, InterfaceImplemented sut)
{
// Arrange
// Act
// Assert
}
}
}
The test currently gives the following error -
"System.InvalidOperationException: No data found for ClassLibrary3.FixtureX.Run_ExecutesUpdateEntityOnce"
I admit that my knowledge of the substitution frameworks here is very limited, so I'm not entirely sure how the theory is expected to function in this instance. However, so far NCrunch does seem to be able to navigate to the test.
Could you please extend this to provide a working sample that can reproduce the problem?