예제 #1
0
        public async Task AddNewsFeedSubscription_Created()
        {
            NewsController controller = new NewsController(mapper, rssFeedProvider, subscriptionRepository);
            NewsFeedSubscriptionUpdateDTO feedSubscriptionDTO = new NewsFeedSubscriptionUpdateDTO()
            {
                Name = "new name",
                Url  = "newUrl.com"
            };
            NewsFeedSubscription feedSubscription = new NewsFeedSubscription()
            {
                Id   = 0,
                Name = "new name",
                Url  = "newUrl.com"
            };

            mapper.Map <NewsFeedSubscription>(feedSubscriptionDTO).Returns(feedSubscription);
            subscriptionRepository.When(x => x.AddAsync(feedSubscription))
            .Do(x => feedSubscription.Id = 5);

            var result = await controller.AddNewsFeedSubscription(feedSubscriptionDTO);

            var createdResult = Assert.IsType <CreatedAtActionResult>(result.Result);
            var resultObject  = Assert.IsType <NewsFeedSubscription>(createdResult.Value);

            Assert.Equal(5, resultObject.Id);
        }
예제 #2
0
        public async Task AddNewsFeedSubscription_BadRequest()
        {
            NewsController controller = new NewsController(mapper, rssFeedProvider, subscriptionRepository);

            var result = await controller.AddNewsFeedSubscription(null);

            Assert.IsType <BadRequestResult>(result.Result);
        }