The IOnlineAVLVehicleService interface inherits from
System.ServiceModel.IClientChannel.
This current configuration throws a BadImageFormat error, where as I
am unaware of any alternative to create multiple remote mocks.
[TestMethod] //Commmunication error on the GetVehicleService
public void
IsGeofenceEventsDisplayedOnMDT_ServiceTimeoutException_InvalidTest()
{
bool isGeofenceEventsDisplayedOnMDT = false;
MockRepository mock = new MockRepository
();
IProxyManager proxyManager =
mock.DynamicMock<IProxyManager>();
IOnlineAVLVehicleService vehicleService =
mock.CreateMultiMock<IOnlineAVLVehicleService>(new Type[] { typeof
(IOnlineAVLVehicleService), typeof(IClientChannel) });
VehicleInterface.GetVehicleDetailResponse vehicleDetailResponse =
GenerateVehicleDetailResponse(false, true);
using (mock.Record())
{
Expect.Call(vehicleService.GetVehicleDetail(new
VehicleInterface.GetVehicleDetailRequest())).IgnoreArguments().Throw
(new TimeoutException());
Expect.Call(proxyManager.GetVehicleService()).Return
(vehicleService).Repeat.Any();
}
using (mock.Playback())
{
isGeofenceEventsDisplayedOnMDT =
GeofenceUtilities.IsGeofenceEventsDisplayedOnMDT(Guid.NewGuid(),
proxyManager);
}
Assert.IsFalse(isGeofenceEventsDisplayedOnMDT);
}
public static bool IsGeofenceEventsDisplayedOnMDT(Guid vehicleID,
IProxyManager proxyManager)
{
if (proxyManager == null)
{
throw new ArgumentNullException("proxyManager");
}
if (vehicleID == Guid.Empty)
{
throw new ArgumentException(string.Format("'vehicleID'
must be a valid vehicle id and not '{0}'", Guid.Empty.ToString()));
}
bool
showPolygonalGeofenceEventsOnMDT =
false;
VehicleInterface.GetVehicleDetailRequest
getVehicleDetailRequest = new
VehicleInterface.GetVehicleDetailRequest();
getVehicleDetailRequest.VehicleID =
vehicleID;
VehicleInterface.GetVehicleDetailResponse
vehicleDetailResponse = null;
VehicleInterface.IOnlineAVLVehicleService
vehicleService = proxyManager.GetVehicleService();
Exception exceptionXXXYZ = ChannelInvoker.Invoke(delegate
(out IClientChannel channel)
{
channel = vehicleService as IClientChannel;
vehicleDetailResponse = vehicleService.GetVehicleDetail
(getVehicleDetailRequest);
});
if (exceptionXXXYZ == null)
{
if (vehicleDetailResponse.OperationStatus)
{
showPolygonalGeofenceEventsOnMDT =
vehicleDetailResponse.VehicleInfo.NotifyDriverOfGeofenceAlert;
}
else
{
throw new ApplicationException("Cannot get vehicle
detail for vehicle:" + getVehicleDetailRequest.VehicleID.ToString());
}
}
else
{
ExceptionManager.HandleException(exceptionXXXYZ,
getVehicleDetailRequest);
}
return showPolygonalGeofenceEventsOnMDT;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/RhinoMocks?hl=en
-~----------~----~----~----~------~----~------~--~---