I am trying to run my unit tests using NCrunch,
however one of the project build is failing with following error -
'Class1' does not contain a definition for 'Property2'
'Class1' does not contain a definition for 'Property2' and no extension method 'Property2' accepting a first argument of type 'Class1' could be found (are you missing a using directive or an assembly reference?)
Class1 is defined as -
public class Class1
{
public List<SomeCustomObject11> Property1 { get; set; }
public List<SomeCustomObject22> Property2 { get; set; }
}
Quite surprisingly, no error is thrown for Property1.
Wondering why the error is thrown only for Property2,
Can anyone please guide what could be the issue?
If this error is appearing consistently (i.e. you can never get the project to build), then my first thought would be that your build environment may have some hidden complexity around project/assembly resolution.
Can you share any more information about how this class is being referenced from other projects within your solution? Do you have any custom build steps or are you using any interesting frameworks that may implement alternative logic around reference resolution?
I've written a C# console app in Visual Studio 2010, "Driver". The Driver is intended to feed work into a publishing system, defined in a local reference (dll) "actify.publishing.system".
I used Visual Studio's built-in ability to "Create Unit Tests...". That created class"Driver.Driver_Accessor" to access the private members of my "Driver" class, which made it easy to write a complete set of unit tests.
I just installed NCrunch, and it insists that my DriverTest project is "failing to build". The error message is "'Driver.Driver_Accessor' does not contain a definition for 'AddJobProperties'", and five similar messages.
My class has many members that do not provoke this error. The six members that do provoke errors use types defined in the local reference, for example actify.publishing.system.PublishingJob. The others uses "standard" types like bool, string, Dictionary, DataTable.
Seems to be something wrong with how NCrunch handles local references in this case.
Does it make any difference if you turn on the 'Copy Referenced Assemblies To Workspace' setting for all the projects in your solution? MS Test private accessors require this, and NCrunch should usually turn it on implicitly, though this doesn't seem to be working reliably in the current build.