Exemple #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);
        }
        protected override Task <AuctionImageQueryResult> HandleQuery(AuctionImageQuery request,
                                                                      CancellationToken cancellationToken)
        {
            var img = _auctionImageRepository.Find(request.ImageId);

            if (img == null)
            {
                return(Task.FromResult(new AuctionImageQueryResult()));
            }
            else
            {
                return(Task.FromResult(new AuctionImageQueryResult()
                {
                    Img = img
                }));
            }
        }