Here is a unit test setup that I am having issues with.... This code exists within a class called TestBase which my unit test classes inherit from....
The issue I am having is when I have the code setup as shown I recieve a NullReferenceException on the Target.Arrange method.... I am using the Q3 release of JustMock.
When I comment out the Target.Arrange line and uncomment the line afterwards, it seems to work as expected.
Here is a snippet of the Target( class under test)
I have InternalsVisibleTo attribute set in my assemblyinfo.cs so the internal visibility shouldn't be causing the issue....
#region Mocked Members
protected
HardCodedSiteOptionsEntity Target;
protected
IDependencyInjection InjectorMock;
protected
IMessageOperations MessageMock;
#endregion
[SetUp]
public
void
InitializeBase()
{
Target = Mock.Create<HardCodedSiteOptionsEntity>(Behavior.CallOriginal);
InjectorMock = Mock.Create<IDependencyInjection>();
MessageMock = Mock.Create<IMessageOperations>();
Target.Arrange(mockedObject => mockedObject.MessageOperationsHelper).Returns(MessageMock);
//Target.MessageOperationsHelper = MessageMock;
}
The issue I am having is when I have the code setup as shown I recieve a NullReferenceException on the Target.Arrange method.... I am using the Q3 release of JustMock.
When I comment out the Target.Arrange line and uncomment the line afterwards, it seems to work as expected.
Here is a snippet of the Target( class under test)
internal
class
HardCodedSiteOptionsEntity : ISiteOptions, IBlockEntityPartBuilder<
uint
>
{
#region Internal Properties
internal
virtual
BitArray StatusMaskData {
get
;
set
; }
internal
virtual
IDependencyInjection InjectorHelper {
get
;
set
; }
internal
virtual
IMessageOperations MessageOperationsHelper {
get
;
set
; }
#endregion
#region Constructor
internal
HardCodedSiteOptionsEntity()
{
InjectorHelper =
new
DependencyInjector();
MessageOperationsHelper = InjectorHelper.InjectEntity<IMessageOperations>();
StatusMaskData =
new
BitArray(32,
false
);
}
}
I have InternalsVisibleTo attribute set in my assemblyinfo.cs so the internal visibility shouldn't be causing the issue....