Exemplo n.º 1
0
        public void GetTags_ReturnsTagsInJson_WhenTagsExists()
        {
            _tagServiceMock.Setup(method => method.GetAll()).Returns(new List <TagDto>());

            var result     = _sut.GetTags();
            var jsonResult = result as JsonResult;

            Assert.NotNull(jsonResult?.Value);
        }
Exemplo n.º 2
0
        private void WhenUserNeedsHelpWhileCreatingTickets()
        {
            var jsonResult = _sut.GetTags() as JsonResult;

            if (jsonResult != null)
            {
                _tagsOutput = jsonResult.Value as IEnumerable <TagApiModel>;
            }
        }
Exemplo n.º 3
0
        public void GetTags(int page, int pageSize)
        {
            // Act
            var controller = new TagsController(_logger, _entityBL, _commonBL);
            var result     = controller.GetTags(string.Empty, page, pageSize) as OkNegotiatedContentResult <PagedList>;

            // Assert

            Assert.AreEqual(result.Content.Content.Count, pageSize);
        }
Exemplo n.º 4
0
        public void GetTags(int id)
        {
            // Act
            var controller = new TagsController(_logger, _entityBL, _commonBL);
            var result     = controller.GetTags(id) as OkNegotiatedContentResult <Tag>;

            // Assert
            Assert.NotNull(result);
            Assert.NotNull(result.Content);
            Assert.AreEqual(id, result.Content.Id);
        }
Exemplo n.º 5
0
        public void GetTags_ReturnNotFoundIfMovieHasNoTags()
        {
            //Arrange
            Mock <ITagRepository> mockTagRepository = new Mock <ITagRepository>();

            mockTagRepository.Setup(tag => tag.GetTags(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns(new List <Tag>());

            var controller = new TagsController(mockTagRepository.Object);

            //Act
            var result = controller.GetTags(213, 1, 100).Result;

            //Assert
            Assert.IsInstanceOf <NotFoundResult>(result);
        }
Exemplo n.º 6
0
        public void testgettag()
        {
            var context = CreateContext.getNewContext("TestingDB");
            var repo    = new TagRepo(context);
            var VC      = new TagsController(repo);
            IEnumerable <Tags> Result = VC.GetTags();

            string[] names = { "Loud", "Fun" };
            int      count = 0;

            foreach (Tags t in Result)
            {
                Assert.Equal(t.Tag, names[count]);
                count++;
            }
        }
Exemplo n.º 7
0
        public void GetTags_GetTagsByMovieId()
        {
            //Arrange
            Mock <ITagRepository> mockTagRepository = new Mock <ITagRepository>();

            mockTagRepository.Setup(tag => tag.GetTags(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>())).Returns((int movieId, int page, int pageSize) =>
                                                                                                                      tags.Where(x => x.movieId == movieId));

            var controller = new TagsController(mockTagRepository.Object);

            //Act
            List <Tag> allTags = (List <Tag>)controller.GetTags(1, 1, 100).Value;

            //Assert
            Assert.IsNotEmpty(allTags);
            Assert.AreEqual(allTags, tags.Where(tag => tag.movieId == 1).ToList());
        }
        public void ApiTagsController_Index()
        {
            //Arrange
            var tagsRepo = new FakeRepository <Tag>(e => e.TagID);

            tagsRepo.Create(new Tag()
            {
                TagID    = 1,
                TagLabel = "testing"
            });

            //Act
            var controller = new TagsController(tagsRepo);
            var result     = controller.GetTags() as IEnumerable <TagApi>;

            //Assert
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.ToList());
            Assert.IsTrue(result.ToList().Count() > 0);
        }
Exemplo n.º 9
0
        public void GetTags_WhenCalled_ReturnsOk()
        {
            var okResult = _controller.GetTags();

            Assert.IsType <OkObjectResult>(okResult.Result);
        }