public async Task UseCase_WhenPersonNewsExists_ReturnNotFound() { var repo = new Mock <INewsRepository>(); var imgService = new Mock <IImageStorageService>(); var validator = ValidatorFactory.GetValidValidator <ThumbnailRequest>(); var logger = new Mock <ILogger <CreateOrUpdateThumbnailUseCase> >().Object; var useCase = new CreateOrUpdateThumbnailUseCase(repo.Object, imgService.Object, logger, validator); var response = await useCase.Execute(_request); response.Status.Should().Be(UseCaseResponseStatus.ResourceNotFountError); response.Errors .Should() .NotBeNullOrEmpty() .And.Contain(x => x.Code == "0.10"); }
public async Task UseCase_WhenUpdateThumbnail_ReturnRemoteUrl() { var repo = new Mock <INewsRepository>(); var imgService = new Mock <IImageStorageService>(); var validator = ValidatorFactory.GetValidValidator <ThumbnailRequest>(); var logger = new Mock <ILogger <CreateOrUpdateThumbnailUseCase> >().Object; repo.Setup(r => r.GetById(_request.NewsId)) .ReturnsAsync(new NewsBuilder(_request.NewsId).WithThumbnailURL("http://s3.com/bucketName/ab123cdf3243.jpg").Build()); imgService.Setup(s => s.Update(It.IsAny <string>(), _request.FileLocalPath)) .ReturnsAsync((string keyName, string path) => $"http://s3.com/bucketName/{keyName}"); var useCase = new CreateOrUpdateThumbnailUseCase(repo.Object, imgService.Object, logger, validator); var response = await useCase.Execute(_request); response.Status.Should().Be(UseCaseResponseStatus.Success); response.Result .Should() .NotBeNullOrEmpty() .And.Contain("http"); }