Ejemplo n.º 1
0
        public void ShouldRetrieveTagPictures()
        {
            var tagName = "myTag";

            var mockRepository = new Mock <ITagRepository>();

            mockRepository.Setup(r => r.GetPictures(tagName)).Returns(() =>
            {
                var result = new List <PictureTag>();
                result.Add(new PictureTag()
                {
                    PictureId = Guid.NewGuid(), TagName = tagName
                });
                result.Add(new PictureTag()
                {
                    PictureId = Guid.NewGuid(), TagName = tagName
                });
                return(result.AsQueryable());
            });

            var tagsController = new TagsController(mockRepository.Object);
            var pictureTags    = tagsController.Pictures(tagName);

            Assert.AreEqual(pictureTags.Count(), 2);
            foreach (var pictureTag in pictureTags)
            {
                Assert.AreEqual(pictureTag.TagName, tagName);
            }
        }