public void testGetAllRestaurants() { IRestaurantPollManager restaurantPollManager = Substitute.For <IRestaurantPollManager>(); restaurantPollManager.GetAllRestaurants().Returns(RestaurantPoll); RestaurantPollController controller = new RestaurantPollController(restaurantPollManager); var result = controller.GetAllRestaurants() as OkNegotiatedContentResult <RestaurantPoll>; Assert.AreEqual(2, result.Content.AvailableRestaurants.ToList().Count); Assert.AreEqual(RestaurantPoll.AvailableRestaurants.ToList()[0].Id, result.Content.AvailableRestaurants.ToList()[0].Id); Assert.AreEqual(RestaurantPoll.AvailableRestaurants.ToList()[0].Name, result.Content.AvailableRestaurants.ToList()[0].Name); Assert.AreEqual(RestaurantPoll.AvailableRestaurants.ToList()[0].Votes, result.Content.AvailableRestaurants.ToList()[0].Votes); Assert.AreEqual(RestaurantPoll.AvailableRestaurants.ToList()[1].Id, result.Content.AvailableRestaurants.ToList()[1].Id); Assert.AreEqual(RestaurantPoll.AvailableRestaurants.ToList()[1].Name, result.Content.AvailableRestaurants.ToList()[1].Name); Assert.AreEqual(RestaurantPoll.AvailableRestaurants.ToList()[1].Votes, result.Content.AvailableRestaurants.ToList()[1].Votes); Assert.AreEqual(1, result.Content.BlockedRestaurants.ToList().Count); Assert.AreEqual(RestaurantPoll.BlockedRestaurants.ToList()[0].Id, result.Content.BlockedRestaurants.ToList()[0].Id); Assert.AreEqual(RestaurantPoll.BlockedRestaurants.ToList()[0].Name, result.Content.BlockedRestaurants.ToList()[0].Name); Assert.AreEqual(RestaurantPoll.BlockedRestaurants.ToList()[0].Votes, result.Content.BlockedRestaurants.ToList()[0].Votes); }
public IHttpActionResult GetAllRestaurants() { return(Ok(restaurantPollManager.GetAllRestaurants())); }