Exemplo n.º 1
0
 public async Task <IActionResult> UpdateDelegateOffer(Guid id, UpdateDelegateOfferModel updateDelegateOfferModel, [FromHeader(Name = "Authorization")] string jwt)
 {
     try
     {
         return(Ok(await _delegateService.UpdateDelegateOffer(id, updateDelegateOfferModel, jwt)));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
        public async Task UpdateProduct_EmptyTitleFailed()
        {
            const string titleText       = "Title Text";
            const string descriptionText = "Description Text";
            var          id  = Guid.NewGuid();
            const string jwt = "";

            var product = new DelegateOffer
            {
                Id          = id,
                Title       = titleText,
                Description = descriptionText
            };

            var updatedProduct = new DelegateOffer
            {
                Id          = id,
                Title       = "",
                Description = "New Description"
            };

            var updateProductModel = new UpdateDelegateOfferModel
            {
                Title       = updatedProduct.Title,
                Description = updatedProduct.Description
            };

            _marketplaceRepository.Setup(x =>
                                         x.UpdateDelegateOffer(product.Id, product)).ReturnsAsync(updatedProduct);

            var result = await Assert.ThrowsAsync <EmptyFieldException>(() =>
                                                                        _marketplaceService.UpdateDelegateOffer(product.Id, updateProductModel, jwt));

            Assert.NotNull(result);
            Assert.IsType <EmptyFieldException>(result);
        }