On another forum I found out how to mock the Operational context in this snippet
what I want to do is mock the endpoint in it now, My unit test here needs to test all aspects and I am having issues actually mocking the endpoint
truthfully I do not know what needs to be mocked or how but I know what I want the end result to be. I just need to be able to get endpoint to not be null and set
retVal = endpoint.Address;
Ive tried so many things that I could not get a result
The code:
public static string GetCallerIPAddress()
{
string retVal = null;
if (OperationContext.Current != null)
{
MessageProperties prop = OperationContext.Current.IncomingMessageProperties;
RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
if (endpoint != null)
{
retVal = endpoint.Address;
}
}
return retVal;
}
what I want to do is mock the endpoint in it now, My unit test here needs to test all aspects and I am having issues actually mocking the endpoint
truthfully I do not know what needs to be mocked or how but I know what I want the end result to be. I just need to be able to get endpoint to not be null and set
retVal = endpoint.Address;
Ive tried so many things that I could not get a result
The code:
public static string GetCallerIPAddress()
{
string retVal = null;
if (OperationContext.Current != null)
{
MessageProperties prop = OperationContext.Current.IncomingMessageProperties;
RemoteEndpointMessageProperty endpoint = prop[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
if (endpoint != null)
{
retVal = endpoint.Address;
}
}
return retVal;
}