private HttpResponseMessage SendGetRestaurantsRequest(int townId, IRestaurantsData data) { var model = new SearchRestaurantsBindingModel { TownId = townId }; var controller = new RestaurantsController(data); this.SetupController(controller); var response = controller.GetRestaurants(model) .ExecuteAsync(CancellationToken.None).Result; return response; }
public void InitTest() { this.mocks = new MockContainer(); this.mocks.PrepareMocks(); this.mockContext = new Mock<IUnitOfWorkData>(); this.mockContext.Setup(c => c.Restaurants).Returns(this.mocks.RestaurantRepositoryMock.Object); this.controller = new RestaurantsController(this.mockContext.Object); this.controller.Request = new HttpRequestMessage { RequestUri = new Uri("http://localhost") }; this.controller.Configuration = new HttpConfiguration(); this.controller.Configuration.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}", new { id = RouteParameter.Optional }); }