Beispiel #1
0
        public ConvertImage_AcceptanceTest()
        {
            _container = CreateDIContainer();
            _dbContext = _container.Resolve <ImageEditAppContext>();
            var editTaskProgressRepository = _container.Resolve <IImgTaskProgressRepository>();
            var editTaskResultRepository   = _container.Resolve <IImgTaskResultRepository>();
            var imgRepository = new ImgRepository(_dbContext, _container.Resolve <IMapper>());
            var mqService     = _container.Resolve <IMessageQueueService>();

            _editTaskService          = new ImgTaskService(imgRepository, mqService, editTaskProgressRepository, editTaskResultRepository);
            _imgTaskProgressService   = new ImgTaskProgressService(editTaskProgressRepository);
            _editImgTaskResultService = new ImgTaskResultService(editTaskResultRepository);

            _container.Resolve <IBusControl>().Start(TimeSpan.FromSeconds(20));
        }
        public void GetTaskResult_when_task_completed_returns_valid_result()
        {
            var groupId              = Guid.NewGuid();
            var taskId               = Guid.NewGuid();
            var expectedResult       = new ImgTaskResult(taskId, groupId, new MemoryStream(new byte[3]), "png");
            var taskResultRepository = new Mock <IImgTaskResultRepository>();

            taskResultRepository.Setup(f => f.GeTaskResult(groupId, taskId))
            .Returns(expectedResult);

            var taskResultService = new ImgTaskResultService(taskResultRepository.Object);
            var result            = taskResultService.GetTaskResult(groupId, taskId);

            result.GroupId.Should().Be(groupId);
            result.TaskId.Should().Be(taskId);
            result.ImgStream.CanRead.Should().BeTrue();
            result.ImgStream.Length.Should().BeGreaterThan(0);
            taskResultRepository.Verify(f => f.GeTaskResult(groupId, taskId), Times.Once());
        }
 public ImgTaskResultController(ImgTaskResultService imgTaskResultService)
 {
     _imgTaskResultService = imgTaskResultService;
 }