public void InitializeAnonymous() { var mock = new Mock <ISmugMugAPI>(); Image invalidImage = null; Image validImage = new Image() { FileName = "ValidFileName.jpg", Title = "Valid Image", Format = "JPG" }; Image unownedImage = new Image() { FileName = "UnownedFileName.png", Title = "Unowned Image", Format = "PNG" }; Image updatedImage = new Image() { FileName = "UnownedFileName.png", Title = "Unowned Image", Format = "PNG", Caption = "Updated caption" }; ImageUpload invalidImageUpload = null; ImageUpload validImageUpload = new ImageUpload() { }; mock.Setup(api => api.GetImage("ValidImage")).ReturnsAsync(validImage); mock.Setup(api => api.GetImage("InvalidImage")).ReturnsAsync(invalidImage); mock.Setup(api => api.GetImage("UnownedImage")).ReturnsAsync(unownedImage); mock.Setup(api => api.UploadImage("ValidAlbum", "ValidImage")).ReturnsAsync(validImageUpload); mock.Setup(api => api.UploadImage("ValidAlbum", "InvalidImage")).ReturnsAsync(invalidImageUpload); Node invalidNode = null; Node validNode = new Node() { Name = "ValidNode", NodeID = "ABCDE", HasChildren = true }; mock.Setup(api => api.GetNode("ValidNode")).ReturnsAsync(validNode); mock.Setup(api => api.GetNode("InvalidNode")).ReturnsAsync(invalidNode); mock.Setup(api => api.UploadImage(validNode, "ValidImage")).ReturnsAsync(validImageUpload); mock.Setup(api => api.UploadImage(validNode, "InvalidImage")).ReturnsAsync(invalidImageUpload); mock.Setup(api => api.UploadImage(invalidNode, "ValidImage")).Throws <ArgumentNullException>(); mock.Setup(api => api.UploadImage(invalidNode, "InvalidImage")).Throws <ArgumentNullException>(); Album invalidAlbum = null; Album validAlbum = new Album() { Name = "ValidAlbum", ImageCount = 5 }; mock.Setup(api => api.GetAlbum("ValidAlbum")).ReturnsAsync(validAlbum); mock.Setup(api => api.GetAlbum("InvalidAlbum")).ReturnsAsync(invalidAlbum); mock.Setup(api => api.UploadImage(validAlbum, "ValidImage")).ReturnsAsync(validImageUpload); mock.Setup(api => api.UploadImage(validAlbum, "InvalidImage")).ReturnsAsync(invalidImageUpload); mock.Setup(api => api.UploadImage(invalidAlbum, "ValidImage")).Throws <ArgumentNullException>(); mock.Setup(api => api.UploadImage(invalidAlbum, "InvalidImage")).Throws <ArgumentNullException>(); mock.Setup(api => api.GetImage(validImageUpload)).ReturnsAsync(validImage); mock.Setup(api => api.GetImage(invalidImageUpload)).Throws <ArgumentNullException>(); mock.Setup(api => api.UpdateImage(validImage, It.Is <Dictionary <string, string> >(i => i.ContainsKey("Caption")))).ReturnsAsync(updatedImage); mock.Setup(api => api.UpdateImage(validImage, It.Is <Dictionary <string, string> >(i => i.ContainsKey("Invalid")))).Throws <HttpRequestException>(); mock.Setup(api => api.UpdateImage((Image)null, It.IsAny <Dictionary <string, string> >())).Throws <ArgumentNullException>(); mock.Setup(api => api.UpdateImage(validImage, null)).Throws <ArgumentNullException>(); mock.Setup(api => api.DeleteImage(invalidImage)).Throws <ArgumentNullException>(); mock.Setup(api => api.DeleteImage(unownedImage)).Throws <HttpRequestException>(); api = mock.Object; }