public void WhenUpdateImageTitleIsExecutedWithInvalidModel_CommandIsNotSent() { Controller.ModelState.AddModelError("whatever", "whatever"); Controller._UpdateImageTitle("whatever", new UpdateImageTitleInput()); CommandInvokerMock.Verify(x => x.Execute(It.IsAny <UpdateImageTitleCommand>()), Times.Never()); }
public void WhenNewImageIsSubmittedWithInvalidModelState_CommandIsNotSent() { Mock <HttpPostedFileBase> postedFileMock = new Mock <HttpPostedFileBase>(); Controller.ModelState.AddModelError("Something", "Something"); Controller.New("userId", postedFileMock.Object, new ImageNewViewModel()); CommandInvokerMock.Verify(x => x.Execute(It.IsAny <UploadUserImageCommand>()), Times.Never()); }
public void WhenUpdateImageTitleIsExecutedWithValidModel_CommandIsSent() { var input = new UpdateImageTitleInput() { Title = "title" }; Controller._UpdateImageTitle("imageId", input); CommandInvokerMock.Verify(x => x.Execute(It.Is <UpdateImageTitleCommand>(y => y.Title == "title")), Times.Once()); }
public void When_UpdateImageTagsIsExecutedWithValidModel_CommandIsSent() { var input = new UpdateImageTagsInput() { Tags = new[] { "1", "2" } }; Controller._UpdateImageTags("imageId", input); CommandInvokerMock.Verify(x => x.Execute(It.Is <UpdateImageTagsCommand>( y => y.Tags[0] == "1" && y.Tags[1] == "2" && y.ImageId == "imageId")), Times.Once()); }
public void WhenNewImageIsSubmittedWIthValidModelAndFile_CommandIsSent() { Mock <HttpPostedFileBase> postedFileMock = new Mock <HttpPostedFileBase>(); int length = 100; postedFileMock.Setup(x => x.InputStream.Read( It.Is <byte[]>(array => array.Length == length), 0, length)).Returns(length); Controller.New("userId", postedFileMock.Object, new ImageNewViewModel()); CommandInvokerMock.Verify(x => x.Execute(It.IsAny <UploadUserImageCommand>()), Times.Once()); }
public void WhenNewImageIsSubmittedWithValidModelStateButNoFile_CommandIsNotSent() { Controller.New("userId", null, new ImageNewViewModel()); CommandInvokerMock.Verify(x => x.Execute(It.IsAny <UploadUserImageCommand>()), Times.Never()); }