public void TestInitialize()
        {
            this.imageService = new Mock <IImageService>(MockBehavior.Strict);
            this.logger       = new Mock <ILogger>();

            this.storageAccount = new Mock <ICloudStorageAccount>();
            this.blobClient     = new Mock <ICloudBlobClient>();
            this.container      = new Mock <ICloudBlobContainer>();
            this.output         = new Mock <ICloudBlockBlob>();
            this.output2        = new Mock <ICloudBlockBlob>();

            this.input = new Mock <ICloudBlockBlob>();
            var inputProperties = new Mock <IBlobProperties>();

            inputProperties.Setup(v => v.CacheControl).Returns("cache-control");
            this.input.Setup(v => v.Properties).Returns(inputProperties.Object);
            input.Setup(v => v.SetMetadataAsync()).Returns(Task.FromResult(0));

            this.inputMetadata = new Dictionary <string, string>();
            this.input.Setup(v => v.Metadata).Returns(this.inputMetadata);

            this.storageAccount.Setup(v => v.CreateCloudBlobClient()).Returns(this.blobClient.Object);
            this.blobClient.Setup(v => v.GetContainerReference(ContainerName)).Returns(this.container.Object);
            this.container.Setup(v => v.GetBlockBlobReference(OutputBlobName)).Returns(this.output.Object);
            this.container.Setup(v => v.GetBlockBlobReference(OutputBlobName2)).Returns(this.output2.Object);

            this.outputProperties = new Mock <IBlobProperties>();
            this.output.Setup(v => v.Properties).Returns(this.outputProperties.Object);
            this.output.Setup(v => v.SetPropertiesAsync(CancellationToken.None)).Returns(Task.FromResult(0));
            this.outputProperties.SetupProperty(v => v.ContentType, null);
            this.outputProperties.SetupProperty(v => v.CacheControl, null);

            this.outputProperties2 = new Mock <IBlobProperties>();
            this.output2.Setup(v => v.Properties).Returns(this.outputProperties2.Object);
            this.output2.Setup(v => v.SetPropertiesAsync(CancellationToken.None)).Returns(Task.FromResult(0));
            this.outputProperties2.SetupProperty(v => v.ContentType, null);
            this.outputProperties2.SetupProperty(v => v.CacheControl, null);

            this.outputMetadata  = new Dictionary <string, string>();
            this.outputMetadata2 = new Dictionary <string, string>();
            this.output.Setup(v => v.Metadata).Returns(this.outputMetadata);
            this.output2.Setup(v => v.Metadata).Returns(this.outputMetadata2);

            this.outputStream = new MockCloudBlobStream();
            this.output.Setup(v => v.OpenWriteAsync(CancellationToken.None)).ReturnsAsync(this.outputStream);

            this.outputStream2 = new MockCloudBlobStream();
            this.output2.Setup(v => v.OpenWriteAsync(CancellationToken.None)).ReturnsAsync(this.outputStream2);

            this.target = new ThumbnailProcessor(this.imageService.Object);
        }
        public async Task WhenCreatingThumbnailFromImageWithExifRotation_ItShouldOrientTheImage()
        {
            int width  = -1;
            int height = -1;

            this.imageService.Setup(v => v.Resize(It.IsAny <MagickImage>(), this.outputStream, Message.Items[0].Width, Message.Items[0].Height, Message.Items[0].ResizeBehaviour, Message.Items[0].ProcessingBehaviour))
            .Callback <MagickImage, Stream, int, int, ResizeBehaviour, ProcessingBehaviour>(
                (a, b, c, d, e, f) =>
            {
                width  = a.Width;
                height = a.Height;
                a.Resize(Message.Items[0].Width, Message.Items[0].Height);
            })
            .Verifiable();

            var originalImageOutputStream = new MockCloudBlobStream();

            this.input.Setup(v => v.OpenWriteAsync(CancellationToken.None))
            .ReturnsAsync(originalImageOutputStream)
            .Verifiable();

            CreateThumbnailSetResult result;

            using (var inputStream = SampleImagesLoader.Instance.ExifRotated.Open())
            {
                this.input.Setup(v => v.OpenReadAsync(It.IsAny <CancellationToken>())).ReturnsAsync(inputStream);
                result = await this.target.CreateThumbnailSetAsync(
                    Message,
                    this.input.Object,
                    this.storageAccount.Object,
                    this.logger.Object,
                    CancellationToken.None);
            }

            this.imageService.Verify();
            this.input.Verify();
            Assert.AreEqual(SampleImagesLoader.Instance.ExifRotated.Width, width);
            Assert.AreEqual(SampleImagesLoader.Instance.ExifRotated.Height, height);
            Assert.AreEqual("75", this.outputMetadata["width"]);
            Assert.AreEqual("100", this.outputMetadata["height"]);
            Assert.AreEqual(SampleImagesLoader.Instance.ExifRotated.Width.ToString(), this.inputMetadata["width"]);
            Assert.AreEqual(SampleImagesLoader.Instance.ExifRotated.Height.ToString(), this.inputMetadata["height"]);
            Assert.AreEqual(SampleImagesLoader.Instance.ExifRotated.Width, result.RenderWidth);
            Assert.AreEqual(SampleImagesLoader.Instance.ExifRotated.Height, result.RenderHeight);
        }