public void GetImage_Returns_Image_When_Media_Is_Not_Folder_And_Is_Convertable()
        {
            var id    = 123;
            var image = new MediaImageModelSubType
            {
                Url            = "/",
                Height         = 120,
                Width          = 60,
                AdditionalText = "abc"
            };

            _umbracoWrapper.Setup(x => x.TypedMedia(id)).Returns(_mediaContent.Object);
            _mediaContent.Setup(x => x.DocumentTypeAlias).Returns(MediaTypes.Image);
            _mediaContent.Setup(x => x.Url).Returns("/image.jpg");
            _umbracoWrapper.Setup(x => x.HasProperty(_mediaContent.Object, "umbracoHeight")).Returns(true);
            _umbracoWrapper.Setup(x => x.HasProperty(_mediaContent.Object, "umbracoWidth")).Returns(true);
            _modelConverter.Setup(x => x.ToModel(typeof(MediaImageModelSubType), _mediaContent.Object, null)).Returns(image);

            var result        = (MediaImageModelSubType)MediaService().GetImage(typeof(MediaImageModelSubType), id);
            var genericResult = MediaService().GetImage <MediaImageModelSubType>(id);

            Assert.That(result.Url, Is.EqualTo(image.Url));
            Assert.That(result.Height, Is.EqualTo(image.Height));
            Assert.That(result.Width, Is.EqualTo(image.Width));
            Assert.That(result.AdditionalText, Is.EqualTo(image.AdditionalText));

            Assert.That(genericResult.Url, Is.EqualTo(image.Url));
            Assert.That(genericResult.Height, Is.EqualTo(image.Height));
            Assert.That(genericResult.Width, Is.EqualTo(image.Width));
            Assert.That(genericResult.AdditionalText, Is.EqualTo(image.AdditionalText));
        }
        public void GetImage_Returns_First_Child_Image_When_Media_Is_Folder_And_Has_Convertable_Children()
        {
            var id    = 123;
            var image = new MediaImageModelSubType
            {
                Url            = "/",
                Height         = 120,
                Width          = 60,
                AdditionalText = "abc"
            };

            var childImage = _repository.Create <IPublishedContent>();

            childImage.Setup(x => x.DocumentTypeAlias).Returns(MediaTypes.Image);
            childImage.Setup(x => x.Url).Returns("/child_image.jpg");
            _umbracoWrapper.Setup(x => x.HasProperty(childImage.Object, "umbracoHeight")).Returns(true);
            _umbracoWrapper.Setup(x => x.HasProperty(childImage.Object, "umbracoWidth")).Returns(true);
            _modelConverter.Setup(x => x.ToModel(typeof(MediaImageModelSubType), childImage.Object, null)).Returns(image);

            _umbracoWrapper.Setup(x => x.TypedMedia(id)).Returns(_mediaContent.Object);
            _mediaContent.Setup(x => x.DocumentTypeAlias).Returns(MediaTypes.Folder);
            _mediaContent.Setup(x => x.Url).Returns("/image.jpg");
            _mediaContent.Setup(x => x.Children).Returns(new[] { childImage.Object });
            _umbracoWrapper.Setup(x => x.HasProperty(_mediaContent.Object, "umbracoHeight")).Returns(false);
            _umbracoWrapper.Setup(x => x.HasProperty(_mediaContent.Object, "umbracoWidth")).Returns(false);

            var result        = (MediaImageModelSubType)MediaService().GetImage(typeof(MediaImageModelSubType), id);
            var genericResult = MediaService().GetImage <MediaImageModelSubType>(id);

            Assert.That(result.Url, Is.EqualTo(image.Url));
            Assert.That(result.Height, Is.EqualTo(image.Height));
            Assert.That(result.Width, Is.EqualTo(image.Width));
            Assert.That(result.AdditionalText, Is.EqualTo(image.AdditionalText));

            Assert.That(genericResult.Url, Is.EqualTo(image.Url));
            Assert.That(genericResult.Height, Is.EqualTo(image.Height));
            Assert.That(genericResult.Width, Is.EqualTo(image.Width));
            Assert.That(genericResult.AdditionalText, Is.EqualTo(image.AdditionalText));
        }