public void ShouldSaveAPicture() { var picture = new Picture() { Name = "picture1", Description = "desc of picture1", Tags = string.Empty }; var image = new byte[] { 1, 2, 3 }; var mockStorage = new Mock<IStorageContext>(); mockStorage.Setup(s => s.SaveBlob(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<string>())).Returns(() => { return "http://foo"; }); var repository = new PictureRepository(mockStorage.Object); picture = repository.Save(picture, image); Assert.AreNotEqual(picture.Id, Guid.Empty); Assert.AreEqual(picture.Url, new Uri("http://foo")); mockStorage.Verify(s => s.SaveBlob(It.IsAny<string>(), It.IsAny<byte[]>(), It.IsAny<string>()), Times.Once()); mockStorage.Verify(s => s.AddEntity(It.IsAny<Picture>(), StorageAccountConfiguration.PicturesTable), Times.Once()); mockStorage.Verify(s => s.AddEntities(It.IsAny<IEnumerable<PictureTag>>(), StorageAccountConfiguration.PictureTagTable), Times.Once()); }