Ejemplo n.º 1
0
        public async Task testPostVoteForRestaurantWithInvalidId()
        {
            IRestaurantPollManager restaurantPollManager = Substitute.For <IRestaurantPollManager>();

            restaurantPollManager.PostVoteForRestaurant(10).Returns(ex => { throw new Exception(); });

            RestaurantPollController controller = new RestaurantPollController(restaurantPollManager);

            var result = await controller.PostVoteForRestaurant(10) as BadRequestErrorMessageResult;

            Assert.AreEqual("Out of index", result.Message);
        }
Ejemplo n.º 2
0
        public async Task testPostVoteForRestaurantWithValidId()
        {
            IRestaurantPollManager restaurantPollManager = Substitute.For <IRestaurantPollManager>();

            restaurantPollManager.PostVoteForRestaurant(10).Returns(RestaurantPoll);

            RestaurantPollController controller = new RestaurantPollController(restaurantPollManager);

            var result = await controller.PostVoteForRestaurant(10) 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);
        }