Hi,
I think that I am doing something obviously wrong here but I am not sure exactly what it is despite lots of digging so I'm looking for some help.
I have a test like this where I am sending in the RequestDispatcherFactoryStub
[Test]
public void Remove_LocationType_From_List()
{
//Arrange
RequestDispatcherStub.AddResponsesToReturn(new GetAllLocationTypesResponse { LocationTypes = _locationTypes },
new RemoveLocationTypeResponse { Success = true });
var viewLocatorService = new Mock<IViewLocatorService>();
var eventAggregator = new Mock<IEventAggregator>();
var locationTypeListViewModel = new LocationTypesListViewModel(eventAggregator.Object, RequestDispatcherFactoryStub, viewLocatorService.Object);
locationTypeListViewModel.SelectedLocationType = locationTypeListViewModel.AllLocationTypes[1];
//Act
locationTypeListViewModel.DeleteLocationTypeCommand.Execute();
//Assert
Assert.AreEqual(locationTypeListViewModel.AllLocationTypes.Count, 2);
}
then in the view model I have a call to send the request to Agatha which essentially looks like this
protected virtual T SendMessageToAgatha<T>(Request request) where T : Response
{
var response = RequestDispatcherFactory.CreateRequestDispatcher().Get<T>(request);
return response;
}
However when the RequestDispatcherFactory.CreateRequestDispatcher() call is made I get the following error :- System.InvalidOperationException : Requests where already send. Either add request earlier or call Clear.
Any ideas what I am doing wrong? Any help would be much appreciated. Many thanks in advance