public ActionResult Index(HttpPostedFileBase image)
        {
            if (image == null) return Index("Where's the beef?");
            var imageStreamConverter = new ImageStreamConverter();
            var bitmap = imageStreamConverter.GetBitmapFromPostedFile(image);

            if (bitmap == null) return Index("That's not an image, homie...");

            var serviceBusConnectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
            var blobConnectionString = CloudConfigurationManager.GetSetting("BlobStorage.ConnectionString");

            var storageAccount = CloudStorageAccount.Parse(blobConnectionString);
            var blobClient = storageAccount.CreateCloudBlobClient();
            var container = blobClient.GetContainerReference("images");
            container.CreateIfNotExists();

            var blockReference = container.GetBlockBlobReference(image.FileName);
            var converter = new ImageConverter();
            var bitmapBytes = (byte[])converter.ConvertTo(bitmap, typeof(byte[]));

            blockReference.UploadFromByteArray(bitmapBytes, 0, bitmapBytes.Length);

            var namespaceManager = NamespaceManager.CreateFromConnectionString(serviceBusConnectionString);

            if (!namespaceManager.QueueExists("ImageProcessing"))
            {
                namespaceManager.CreateQueue("ImageProcessing");
            }

            var client = QueueClient.CreateFromConnectionString(serviceBusConnectionString, "ImageProcessing");
            var message = new BrokeredMessage(new ImageMessage { BlobBlockName = blockReference.Name });

            client.Send(message);
            return Index();
        }
        public void FileWithoutImageExtensionShouldReturnNull()
        {
            //Arrange
            var converter = new ImageStreamConverter();
            var httpFileStub = GetStubbedPostedFile("someFile.txt");

            //Act
            var result = converter.GetBitmapFromPostedFile(httpFileStub);

            //Assert
            Assert.IsNull(result);
        }
        public void FileNameWithImageExtensionAndLotsOfPeriodsShouldNotReturnNull()
        {
            //Arrange
            var converter = new ImageStreamConverter();
            var httpFileStub = GetStubbedPostedFileWithImage("some.Image.that.will.be.converted.jpg");

            //Act
            var result = converter.GetBitmapFromPostedFile(httpFileStub);

            //Assert
            Assert.IsNotNull(result);
        }
        public void FileNameWithoutImageExtensionAndLotsOfPeriodsShouldNotBeValidAndReturnNull()
        {
            //Arrange
            var converter = new ImageStreamConverter();

            var httpFileStub = GetStubbedPostedFile("some.File.that.isnt.an.image.txt");

            //Act
            var result = converter.GetBitmapFromPostedFile(httpFileStub);

            //Assert
            Assert.IsNull(result);
        }