public async Task TestImage() { //Perpare TestingContext context = new TestingContext(); InitContext(context); context.DependencyMap[typeof(IBinaryService)] = context.GetService <BinaryService>(); IQuestionService questionService = InitQuestionService(context); //Add Q QuestionDto qdto = new QuestionDto() { Title = "Bla", Explanation = "bla", Language = "De", }; int newId = await questionService.InsertQuestionAsync(qdto); //Add Binary IBinaryService binaryService = context.GetSimple <IBinaryService>(); int id = await binaryService.AddBinaryAsync(new BinaryDto { ContentDisposition = "ContentDisposition", ContentType = "ContentType", FileName = "FileName", Name = "Name", Length = 2334, }); ImageDto imageDto = new ImageDto() { IdBinary = id, Full = false, Height = 124, Width = 64, }; imageDto = await questionService.AddImageAsync(imageDto); QuestionDto questionDto = await questionService.GetQuestionAsync(newId); questionDto.Images.Add(imageDto); await questionService.UpdateQuestionAsync(questionDto); questionDto = await questionService.GetQuestionAsync(newId); Assert.True(questionDto.Images.Count == 1); }
public async Task <ImageDto> AddImage([FromBody] ImageDto image) { return(await _questionService.AddImageAsync(image)); }