public void ShoudThrowWhenTryngToAddImageAsync()
        {
            byte[] bytes = File.ReadAllBytes(@"./MediaContent/image.jpg");

            var newImageInfo = new ImageInfoRequstModel()
            {
                OriginalName      = TestsConstants.ImageInfoBaseOriginalName,
                OriginalExtension = TestsConstants.ImageBaseExstnsion,
                Base64Content     = Convert.ToBase64String(bytes)
            };

            var imageRequestModel = new SaveImageRequestModel()
            {
                Title       = TestsConstants.ImageBaseTitle,
                Description = TestsConstants.DescriptionBaseTextr,
                IsPrivate   = false,
                Tags        = TestsConstants.TagBaseName + "," + TestsConstants.TagBaseName + "Pesho",
                ImageInfo   = newImageInfo
            };


            this.controller
            .CallingAsync(c => c.Post(imageRequestModel))
            .ShouldReturn()
            .HttpResponseMessage();
        }
Beispiel #2
0
        public async Task <IHttpActionResult> Post(SaveImageRequestModel model)
        {
            var autenticatedUserId = this.User.Identity.GetUserId();
            var imageTags          = await this.tagsService.TagsFromCommaSeparatedValues(model.Tags);

            var imageAlbums =
                await this.albumssService.AlbumsFromCommaSeparatedValuesAndUserId(model.Albums, autenticatedUserId);

            var resizedRawFile = await this.imagesService.ProcessImage(model.ImageInfo.ToRawFile());

            var addedImageId = await this.imagesService.Add(
                model.Title,
                autenticatedUserId,
                model.Description,
                model.IsPrivate,
                resizedRawFile,
                imageTags,
                imageAlbums);

            return(this.Ok());
        }
        public void ShoudThrowWhenTryngToAddImageAsync()
        {
            byte[] bytes = File.ReadAllBytes(@"./MediaContent/image.jpg");

            var newImageInfo = new ImageInfoRequstModel()
            {
                OriginalName = TestsConstants.ImageInfoBaseOriginalName,
                OriginalExtension = TestsConstants.ImageBaseExstnsion,
                Base64Content = Convert.ToBase64String(bytes)
            };

            var imageRequestModel = new SaveImageRequestModel()
            {
                Title = TestsConstants.ImageBaseTitle,
                Description = TestsConstants.DescriptionBaseTextr,
                IsPrivate = false,
                Tags = TestsConstants.TagBaseName + "," + TestsConstants.TagBaseName + "Pesho",
                ImageInfo = newImageInfo
            };


            this.controller
                .CallingAsync(c => c.Post(imageRequestModel))
                .ShouldReturn()
                .HttpResponseMessage();
        }