Esempio n. 1
0
        public void DeleteTag_TagNotFound_ResourceNotFoundException()
        {
            var itemToDelete = TagMockData.GetMockTagsWithSetups(mockRepository, 1).Select(c => c.Object).FirstOrDefault();

            mockTagRepository.Setup(tr => tr.FindBy(It.IsAny <int>())).Returns(itemToDelete);

            DeleteTagResponse response = tagService.DeleteTag(new DeleteTagRequest(1));

            mockRepository.VerifyAll();
            Assert.AreEqual(typeof(ResourceNotFoundException), response.Exception.GetType());
        }
Esempio n. 2
0
        public void DeleteTag_ValidTag_Succeed()
        {
            int itemToDelete = 3;
            var mockTags     = TagMockData.GetMockTagsWithSetups(mockRepository, 1).Select(c => c.Object).FirstOrDefault();

            mockTagRepository.Setup(x => x.FindBy(It.IsAny <int>())).Returns(mockTags);
            //mockTagRepository.Setup(x => x.Delete(mockTags));

            DeleteTagResponse response = tagService.DeleteTag(new DeleteTagRequest(itemToDelete));

            mockRepository.VerifyAll();
            mockTagRepository.Verify(t => t.Delete(It.IsAny <Tag>()), Times.Once);
        }
Esempio n. 3
0
        public void GetAllTags_ValidTags_Succeed()
        {
            var mockTags = TagMockData.GetMockTags(mockRepository, 10).ToList();

            mockTagRepository.Setup(cr => cr.Search(It.IsAny <string>())).Returns(mockTags);

            GetTagListResponse response = tagService.GetAllTags(new GetTagListRequest()
            {
                Name = ""
            });
            ITagsListViewModel viewModel = response.TagsListViewModel;

            mockRepository.VerifyAll();
            Assert.AreEqual(mockTags.Count, viewModel.Tags.Count());
            Assert.AreEqual(null, response.Exception);
        }