示例#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());
        }
示例#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);
        }