Exemplo n.º 1
0
        public void AddImage_when_valid_file_adds_image()
        {
            var testFile          = File.ReadAllBytes("./test_image.jpg");
            var imgRepresentation = new AuctionImageRepresentation(new AuctionImageMetadata("jpg"), testFile);

            auctionImageRepository.Add("img1", imgRepresentation);
            var fetched = auctionImageRepository.Find("img1");

            fetched.Metadata.IsAssignedToAuction.Should()
            .BeFalse();
            fetched.Should()
            .NotBeNull();
            fetched.Img.Length.Should()
            .Be(testFile.Length);
        }
Exemplo n.º 2
0
        private void AddConvertedImage(string imageId, AuctionImageSize size, AuctionImageRepresentation imgRepresentation)
        {
            AuctionImageRepresentation converted = null;

            try
            {
                converted = _imageConverterService.ConvertTo(imgRepresentation, size);
            }
            catch (Exception ex)
            {
                throw new DomainException("Cannot convert image", ex);
            }

            try
            {
                _imageRepository.Add(imageId, converted);
            }
            catch (Exception ex)
            {
                throw new DomainException("Cannot add image", ex);
            }
        }