public void ReturnSuccess_IfConfirmingImageNotFailed() { // Arrange var mockedImageGalleryService = new Mock <IImageGalleryService>(); mockedImageGalleryService.Setup(s => s.ConfirmImage(It.IsAny <string>())) .Verifiable(); var mockedImageFactory = new Mock <IImageFactory>(); var mockedDateProvider = new Mock <IDateProvider>(); var mockedLakeService = new Mock <ILakeService>(); var mockedImageGalleryFactory = new Mock <IImageGalleryFactory>(); var mockedDirectoryHelper = new Mock <IDirectoryHelper>(); var controller = new PicturesController( mockedImageGalleryService.Object, mockedImageFactory.Object, mockedDateProvider.Object, mockedLakeService.Object, mockedImageGalleryFactory.Object, mockedDirectoryHelper.Object); var mockedImageId = "Mocked Image Id"; // Act var result = controller.Confirm(mockedImageId); // Assert StringAssert.Contains("success", result); StringAssert.Contains(GlobalMessages.ConfirmImageSuccessMessage, result); mockedImageGalleryService.Verify(s => s.ConfirmImage(mockedImageId), Times.Once); }
public void GetGalleriesWithunconfirmedImages_FromDatabase_AndRenderDefaultView() { // Arrange var mockedCollection = new List <ImageGalleryModel>(); var mockedImageGalleryService = new Mock <IImageGalleryService>(); mockedImageGalleryService.Setup(s => s.GetGalleriesWithUnconfirmedImages()) .Returns(mockedCollection) .Verifiable(); var mockedImageFactory = new Mock <IImageFactory>(); var mockedDateProvider = new Mock <IDateProvider>(); var mockedLakeService = new Mock <ILakeService>(); var mockedImageGalleryFactory = new Mock <IImageGalleryFactory>(); var mockedDirectoryHelper = new Mock <IDirectoryHelper>(); var controller = new PicturesController( mockedImageGalleryService.Object, mockedImageFactory.Object, mockedDateProvider.Object, mockedLakeService.Object, mockedImageGalleryFactory.Object, mockedDirectoryHelper.Object); // Act var result = controller.Confirm() as ViewResult; var model = result.Model as IEnumerable <ImageGalleryModel>; // Assert Assert.AreEqual(mockedCollection, model); Assert.IsTrue(result.ViewName == ""); mockedImageGalleryService.Verify(s => s.GetGalleriesWithUnconfirmedImages(), Times.Once); }
public void ReturnError_IfConfirmingImageFailed() { // Arrange var mockedImageGalleryService = new Mock <IImageGalleryService>(); mockedImageGalleryService.Setup(s => s.ConfirmImage(It.IsAny <string>())) .Throws <NullReferenceException>(); var mockedImageFactory = new Mock <IImageFactory>(); var mockedDateProvider = new Mock <IDateProvider>(); var mockedLakeService = new Mock <ILakeService>(); var mockedImageGalleryFactory = new Mock <IImageGalleryFactory>(); var mockedDirectoryHelper = new Mock <IDirectoryHelper>(); var controller = new PicturesController( mockedImageGalleryService.Object, mockedImageFactory.Object, mockedDateProvider.Object, mockedLakeService.Object, mockedImageGalleryFactory.Object, mockedDirectoryHelper.Object); // Act var result = controller.Confirm(It.IsAny <string>()); // Assert StringAssert.Contains("error", result); StringAssert.Contains(GlobalMessages.ConfirmImageErrorMessage, result); }